I need to calculate a rollup of dollars where we show parent/child in a grid. When we calculate a summary, we cannot SUM the children again because that'll duplicate the values.
How do I get the context of the rows that are being summed so I know whether or not to include that value? I need to sum all parents and exclude all children.
https://www.igniteui.com/help/api/2021.1/ui.iggridsummaries#options:columnSettings.summaryOperands.summaryCalculator
The current method only provides the values of all records. Even if I grab the datasource of the grid, the method doesn't provide the current column its calculating.
Looking at the attachment:
1. Expanded grid contains parent and child records. The data itself has flags indicating whether its a parent or child.
2. The summary total sums up the columns correctly when its collapsed. (Shaded GREEN)
3. The summary totals duplicates that parent's children when its expanded. (Shaded RED)
How do I have the context of the record in the summaries so I can correctly sum up the values? I tried hooking into the summariesCalculated method but I do not see a clean way to retrieve the HTML object to replace the value. How can I cleanly get this?
Thanks,
No need of proxy for this particular scenario. You can set the name of the function as a string and define it globally.
https://jsfiddle.net/dkamburov/31q4teab/
In razer could be:
.SummaryCalculator("countTrueValues")
<script> function countTrueValues(data) { console.log(data); var i, l = data.length, count = 0, elem; for (i = 0; i < l; i++) { elem = data[i]; if (elem === true) { count++; } } return "<span style='color:red;'>" + count + "</span>"; } </script>
Why did you proxy the summary calculator method? I know that passes in the current context. But then how can I achieve using Razor syntax?
Hello,
I think you can use summaryCalculator function to pass html(here's a fiddle) and rely on the order of the data to get some other fields from the data records.
Regards