cumulative column

cumulative column

saikalyan9981saikalyan9981 Posts: 10Questions: 3Answers: 0
edited July 2018 in Free community support

Is there a way to add a column with cumulative values? For example,

I have a table:

id | product | price
1 | camera | 200
2 | watch | 100
3 | pencil | 20
4 | wallet | 10

I want to add an extra column and make the table like this:

id | product | price | cumulative price |
1 | camera | 200 | 200 |
2 | watch | 100 | 300 |
3 | pencil | 20 | 320 |
4 | wallet | 10 | 330 |

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Its possible, but it isn't something that DataTables will do out of the box. This example shows the basic principle, you would need to modify it to do the cumulative sum.

    Allan

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    edited July 2018

    Hi @saikalyan9981 ,

    You can use drawCallback, as in this example.

    Cheers,

    Colin

This discussion has been closed.