footerCallback does not compute sum for a fixedColumn when filter is applied

footerCallback does not compute sum for a fixedColumn when filter is applied

mj0sephmj0seph Posts: 7Questions: 2Answers: 0

Hello!

I would like to compute a column's sum (Salary, in this case) which is (1) also a fixedColumn and (2) subject to any applied filtering. In this example, I've commented the fixedColumn options out demonstrating that the filtered salaries' sum is computed as expected. However, when the fixedColumn options are applied (Name and Salary columns, in this case) the footerCallback sum reflects the total of all salaries regardless of filtering.

Any advice or thoughts on alternative approaches are appreciated!

live.datatables.net/peheboke

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 9,174Questions: 0Answers: 1,533
    Answer ✓

    Hi @mj0seph ,

    You can call fixedColumns().update() whenever the table is drawn, see here - this ensures the fixedColumns' layer gets updated with the new information.

    I had expected that I could do this in the footerCallback, but for some reason that's causing an error. I've raised it internally (DD-1180 for my reference) and we'll report back here when there's an update.

    For the meantime, the draw should do the trick as shown above.

    Cheers,

    Colin

  • mj0sephmj0seph Posts: 7Questions: 2Answers: 0

    Thanks, @colin ! That worked perfectly. I appreciate your quick and helpful response.

Sign In or Register to comment.