I’m trying to use a xamDataGrid to display hierarchical data where every parent is just a sum of it’s children. For example, I want to display various types of information about cities around the world. At first my grid might first show the totals of each continent (one row per continent, with columns for Population, GDP, Annual rain fall, etc). A user should be able to expand a continent to see the totals for each Country and further expand that to see the data for each city.
What would be the best way to accomplish this? Should each parent be a list that holds lists of its children and then bind to the highest level list? Or would I be better off creating custom objects for each parent? Or is this functionality already built-in? Can the xamDataGrid automatically show sums of sums?
I am developing in WPF and using Entity Framework to hold the lowest level data (not the sums).
HI,
I am attaching a sample application that should meet your requirements.
Here a link on summaries:
http://help.infragistics.com/NetAdvantage/WPF/Current/CLR4.0/?page=xamDataGrid_Row_Summaries.html
Sincerely,
Matt
Development Support Engineer
Hi Matt,
Thanks for the quick reply.
Unfortunately your sample solution will not work for our requirements. I am actually trying to create a grid where the sums are just like any other row and we would be able to have multiple layers deep, (sums within sums within sums). I’ve tried to take a screen shot of what we’re trying to achieve (see attached image).
As you can see we have the totals for 2 Continents, if you expand a Continent you will see the totals for each Country in that Continent, if you expand a Country you will see the data for each City in that Country. Note that the data for the parent rows (Country) is just a total of it’s children’s rows (Cities).
From what I’ve seen, I don’t think this can be done using summary xamDataGrid row summaries. I’m guessing it’ll be how we store our hierarchy and the relationships within our data. If this is true how would we properly do this? CollectionViews of CollectionViews which hold lists…?
Thanks
I modified the sample to add the columns dynamically at run time.
The XamDataGrid will automatically create fields for any public properties in the class that it is bound to.
So I only need to add two unbound fields.
Please review my sample.
Developer Support Engineer
Hi,
Is it possible to dynamically generate my grid’s Fields during runtime instead of how we’re doing it in the sample solution you provided.
The reason I am trying to do this is because the rows will have a different number of children. Some may only have the parent and 1 child whereas others may have the parent with possibly 5+ children and each one of those may have its own children.
I think I can do this if the parents and children were bound to the same object but in my case the parent is bound to the sum of all it’s children and the lowest level child is bound to its own value.
Thank so much for your help.
Here a link on on how to change the expansion indicator of the XamDataGrid:
http://ko.infragistics.com/community/forums/p/66014/380166.aspx
Is there any way to change the + symbol to >??
Your solution was exactly what I was trying to do.
Thank you for your help!