Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
Igx Data Grid - Summaries - How to display sum for a column using the response from backend request instead of IgxNumberSummaryOperand
posted

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

Parents
No Data
Reply
  • 640
    Offline posted

    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 Kombov
    Entry Level Software Developer
    Infragistics, Inc.

Children