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
Hi Andy,
You might try playing around with the SummaryDisplayAreas settings. I think if you use one of the settings that creates fixed summaries, it will show a grand total.
jandyn said: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?
You are correct, there's no way to do this. Toggling the Hidden property of the band is fine, but it will hide the band under all parents, not just the current row.
Hi,
It seems to me that what you need to do is add an unbound column to the parent table and populate it with the value of the summary from the rows.Then you can have a summary on the parent table that sums up the summaries on the child table.
I threw together a simple example of this and I am attaching it here.
In the sample, I left the unbound column visible, just so you can see it, but you will probably want it hidden. So just set the hidden property to true inside InitializeLayout. I put the code in there and commented it out.
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(
))
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.