Working on the visible rows within a column
Working on the visible rows within a column
Hi,
I'm new to DataTables and impressed by what I've seen so far. However, I've run into some problems and, after several hours of searching, I guess I'm looking in the wrong place (and or in the wrong way).
My immediate problem is that I am trying to sum the visible (search filtered) values in a column (ideally using the sort values), but cannot seem to get it working.
I am trying to use:
myDT
.columns('mySelector', { page: 'current', search: 'applied' })
.every(function() {
this.data().sum();
})
But it still includes the filtered rows in the sum. (Pagination is actually disabled, but I have tried with and without the "page: current" option without success)
What is the recommended way to retrieve and work with the data from only the visible rows?
Also, some secondary questions have come up...
- is there a recommended way to retrieve the sort / search orthogonal data instead of the display data for a given column/row?
- Is there a way to prime/refresh the cache for a given column/row? I have tried using
column().cache('order')
to get the sort data, but it only works if you have already sorted on that column. I have several columns I'd like to sum but at the moment I am calling order(xxx).draw() several times just to prime the cache and this seems a bit heavy handed. A column.primeCache('order') method would be cuter!
Many thanks!
C