I have a hierarchical grid with a parent and 2 children and I have got summaries showing on some fields in one of the children.
Something like this:
Contract
---Invoices
---Estimates
Each of them is bound to a datatable in a dataset. In the Estimates child I'm showing a quantity column which gets summed for the lines for that contract and that summary works.
Is it possible to show grandtotals for a child column across all the parents? In my case I need to sum the quantity column for all the Contracts.
If it's not do-able with what's built into the grid and it's members, can I get there by maybe adding an unbound column to the parent that has a formula that sums it's children and then summarize that parent column?
Worst case, I can add textboxes to the form to show a sum from the child datatable but I'd rather not do that...
Another question that I have related to this same grid is: can I collapse just one of the children? Keep showing the Estimates but collapse the Invoices? Since there is just a + up at the Contract which collapses both children, I'm guessing not. I've found I can toggle the Band's Hidden property and that doesn't seem cause any problems and it seems fairly quick: If the answer to my question about collapsing is No, are there any problems with toggling the the Hidden property that make it a bad idea?
Thanks,
Andy
I attached a revised sample that refreshes the summaries and cells by hooking on AfterExitModeEnded and calling
grid.Rows.Refresh(FireInitializeRow)
The options depend on the data type of the value. So for a numeric summary, you can refer to Microsoft's documentation on the numeric formats:
Standard Numeric Format Strings
Custom Numeric Format Strings
I finally figured that out and aligned it to the right and it looks fine now. I do have another question. For reference purposes where can I go to see viable options for the displayformat property of the summary row? The online documentation only had one example.
Well, I think the way you are adding this summary, the summary will be aligned with the unbound (hidden) column. So you need to use a different overload of the Summaries.Add method. There are overloads that allow you to specify a different column to align to, or you could align the summary left, right, or center.
Mike,
I"ve created an example as you suggested above but my summary line does not display if the unbound column is hidden. If I don't hide it then I see the summary line and it contains the totals of the child rows which I set durning the initializerow event. I create the summay during the initializelayout event using code such as:
e.Layout.Bands(0).Summaries.Add(UltraWinGrid.SummaryType.Sum, e.Layout.Bands(0).Columns(
))