help with columns().data()

help with columns().data()

i.stefan.kissi.stefan.kiss Posts: 3Questions: 1Answers: 0

So there is this following test case
http://live.datatables.net/lunetiri/1/

What i want to do is to sum up the values on a column only for the selected rows.
As you can see in code i have managed to sum up the entire column for the 'filtered' rows. However
var data = api.column( col ,{selected:true}).data();
-> this always seem to return undefined....

couple of things i have noted:
- selecting/deselecting does not trigger a footer refresh
- doing a search does trigger a footer refresh while keeps the selected rows selected.- however the data is still undefined.

Questions:
1. what is the correct way of getting /summing the contents of the cells of a column for selected rows ?
2. Bonus question ... how do i trigger a footer refresh on select/deselect ?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi i.stefan.kiss!

    This example here covers both your questions. Your problem was that you were specifying a selected column, whereas it's either a cell or a row that has that class - only 'a bit' of a column gets selected!

    Hope that helps,

    Cheers,

    Colin

  • i.stefan.kissi.stefan.kiss Posts: 3Questions: 1Answers: 0

    Thank you ! It works excellent. I had an idea that columns might not be what i was looking for in that case but wasn't sure why! That explains it :)

This discussion has been closed.