How to aggregate data in a FlexGrid with childItems

Posted by: ssmith on 15 August 2019, 2:07 pm EST

    • Post Options:
    • Link

    Posted 15 August 2019, 2:07 pm EST

    I have a FlexGrid #flex bound to a data set that includes childItems.

    I’m using the [aggregate]=“‘Sum’” binding on the columns, and injecting a group row below the data.

    this.flex.columnFooters.rows.push(new wjcGrid.GroupRow());
    this.flex.bottomLeftCells.setCellData(0, 0, 'Σ');
    
    

    The Sum function only calculates the sum of the highest level items and doesn’t include the childItems - is there a way to have the aggregate function recurse down through the data, or if I generate a flattened array of the data, can I have the footer groupRow get the totals from that flattened copy of the data instead?

  • Posted 18 August 2019, 4:07 pm EST

    Hi Stephen,

    The FlexGrid does not calculate the aggregate of the child items, so you will need to calculate it manually. To find the aggregate manually, you will need to create a flat array of data and then use the getAggregate method to find the aggregate. Then use the setCellData method to set the aggregate to the desired cell. Please refer to the sample below:

    https://stackblitz.com/edit/angular-sh5rqr

    Regards,

    Ashwin

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels