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.
I attached a revised sample that refreshes the summaries and cells by hooking on AfterExitModeEnded and calling
grid.Rows.Refresh(FireInitializeRow)