Hello,
I have a currency column that can have multiple currencies. For this reason for the Total Sum I would like to use the response received from a backend request instead of IgxNumberSummaryOperand because all the values need to be converted to one currency and then summed. I tried to implement a custom summary that extends IgxNumberSummaryOperand but I have access only to columnData, allGridData and fieldName and it does not help me.
Is there any way to do this?
Thanks,
Anca
Hello Anca,
Thank you for posting in our community.
What I can suggest in order to change the default appearance of the summary results, is formatting them using the IgxColumnComponent's summaryFormatter property :
public summaryFormatter = (summary: IgxSummaryResult): string => { const result = summary.summaryResult; if (summary.key === 'sum') { return this.theSumFromTheBackEnd; } return result; }
Please keep in mind that since the formatter function is called from another context ( IgxColumnComponent) the properties of your component will not be available there. I would suggest using an arrow function so the "this" context is preserved.
Additionally, please ensure that the summaries are not cached when you are trying to recalculate them. In order to do that, you should clear the gird's summaries cache using its summaryService API:
this.grid.summaryService.clearSummaryCache(); this.grid.summaryService.recalculateSummaries();
I have created a small sample illustrating my suggestion, which you can find here. Please test it on your side and let me know whether you find it helpful.
Regards,Viktor KombovEntry Level Software DeveloperInfragistics, Inc.
Thank you for your answer.
Your solution works perfectly for when there is no grouping in the data-grid. If I make a grouping by a column then all subtotals have the same value with the total sum. Is there any method by which, even when I have group by in data-grid to format the sum and subtotals with values coming from the backend?