Hi,
I am trying to use XamPivotGrid with a following scenario
class A
{
public int Id {get;set;}
public string Description{get;set;}
public List<A> SubLines{get;set;}
}
I will get a list of A (List<A>) from my data access layer and this hierarchy can be any levels deep. Can you please help me in creating a pivot grid out of this case?
Thanks
V
Hello,
Thank you for your post. I have been looking into it and I suggest you organize your data as a flat data. You can do something like this:
class A { public int Id { get; set; } public string Description { get; set; } public A SubLine { get; set; } }
And after that you can add a HierarchyDescriptors in a recursive function to make the data Hierarchical, because the XamPivotGrid doesn’t support Hierarchical collections. Here it is described how to do so:
http://help.infragistics.com/NetAdvantage/WPFDV/2011.2/CLR4.0/?page=xamPivotGrid_US_Defining_Hierarchies_And_Providing_Metadata_With_FlatData.html
Please let me know if you need further clarifications on this matter.
Looking forward for your reply.
"after that you can add a HierarchyDescriptors in a recursive function to make the data Hierarchical"
Can this be done in XAML? If so, could you provide a sample?
FYI my case is this: I have an asymmetrical tree of locations. This means each branch may be of a different breath and depth. Actually there are multiple types in this tree but for the pivot grid we have simplified it.
Current definition (I will wrap the various other collections with getters so they can be used as measures, I will also remove the parent):
internal class Location { /// <summary> /// The id of the Location /// </summary> public Guid Id { get; set; } /// <summary> /// Display name of the location /// </summary> public string DisplayName { get; set; } /// <summary> /// The id of the parent /// </summary> public Guid? ParentId { get; set; } /// <summary> /// The sub locations /// </summary> /// <remarks> /// Empty collection when Inventories is not empty /// </remarks> public ObservableCollection<Location> Children { get; set; } /// <summary> /// Gets or sets the capacity indexes. /// </summary> /// <remarks> /// Empty collection when Inventories is not empty /// </remarks> /// <value> /// The capacities. /// </value> public ObservableCollection<CapacityIndex> Capacities { get; set; } /// <summary> /// Gets or sets the inventories. /// </summary> /// <remarks> /// Empty collection when Capacities is not empty /// </remarks> /// <value> /// The inventories. /// </value> public ObservableCollection<Inventory> Inventories { get; set; }
Hello Teun,
As I originally suggested the data assigned to the FlatDataSource's ItemsSource should be flat, without Properties of Collection or List type. At the link I shared you can see how to define the HierarchyDescriptors both in XAML and code. If you want many levels in depth I can suggest you use code, because you can use recursive function to create the descriptors while in XAML you have to define every one manually.
Hope this helps you.