Hi,
In my application, for the wingrid i have added a Summary for few of the columns. The summary works fine when the grid is bounded with data. Also when any filter is applied for any of the grid columns etc.
For the gird i have set the option to select multiple rows (by moving the mouse over rows headers , also holding the shift button and click on the required rows)
Now we want to refresh the Summary total for the selected records (rows). (sample screen shot attached, selected records background color are changed)
Can anyone suggest how to refresh the summary for the only selected rows ?
Thanks,
Narasimha
You can create a class that implements the ICustomSummaryCalculator interface (only three methods). This is the interface with which the grid's summary compilation logic communicates, so you effectively take control over the summary calculations by doing this. In your 'AggregateCustomSummary' method implementation, you would add the cell values only for the selected rows.
i have the same problem as nranga shown in the msg before.
I implemented a class based on iCustomSummaryCalculator. In the 'AggregateCustomSummary' i add only when row.selected is true. It doesn't work.
The SummaryCalculator will only reached one-times after filling the grid (I set a stop at BeginCustomSummary), but not when i select a row ore also more rows.
I assumed that the SummaryCalculator will start to recalculate after changing selection. But it isn't.
How can I initialize the recalculating, maybe from after selectchanged event or similiar.
Any help is welcomed.
Wolfgang
Hi Mike,
thank you for your fast answer. Now work all fine and the customer is satisfied.
Sorry, this was my mistake. The RefreshSummaries method only applies to summaries that were added or removed.
To force a recalculation of a summary, you would do this:
UltraGrid grid = (UltraGrid)sender; grid.DisplayLayout.Bands[0].Summaries[0].Refresh();
I used index 0 here, but obviously you will want to use the index, or more likely the Key, of the summary you need to refresh.
ewg said:By the way another question: Is it possible show the Summarylines everytimes on the visible part from the grid (on the first page) like the addnew-line?
Yes, you can do this using the SummaryDisplayArea property on the Override object. This is a flagged enumeration, so you can specify mutliple areas.
In your case, you will want to use TopFixed or BottomFixed in addition to any other areas you want to the summaries to appear in.
thanks for your answer.
I tried it, but after .RefreshSummaries nothing happens.
I see following behaviour: When i have a table with many lines (more as on screen has space) and the summary lines on the bottom are not visible, then can i mark some lines. I scroll now down that the summaries are come visible and the right value is in the summary field. The summarycalculator will be reached (i had a stop on BeginCustomSummary in debug) when the summaryfields are coming visible on screen. When i now change the selection one more, then event afterselectchange will be fired, but the RefreshSummaries don't reach the BeginCustomSummary.
What could i do wrong?
By the way another question: Is it possible show the Summarylines everytimes on the visible part from the grid (on the first page) like the addnew-line?
I hope, you have some tips for me.
Best Regard from Munich
PS: I use VB.net VS2010 and tried it with Infragistics 10.1 and also 10.2
Hi Wolfgang,
There's no way for the grid to know what your ICustomSummaryCalculator is doing. It does not know that you are basing the summary on selection. So it does not automatically recalculate the summaries when the selection changes.
So you just have to tell it when the summaries need to be recaculated. Like so:
private void ultraGrid1_AfterSelectChange(object sender, AfterSelectChangeEventArgs e) { UltraGrid grid = (UltraGrid)sender; grid.DisplayLayout.RefreshSummaries(); }