Accessing filtered data
Accessing filtered data

How do I access just the data that has been filtered? I am able to apply a filter using the example code (below) and implemented some extra code to get just my results. Am I doing this wrong?
Thanks!
var table = $('#example').DataTable();
var scratchData = [];
var filteredData = table
.columns( [4] )
.data()
.eq( 0 )
.filter( function ( value, index ) {
if(value === filter) {
scratchData.push(this.rows(index).data())
}
} );
}
This question has accepted answers - jump to:
This discussion has been closed.
Answers
The selector functions accept a
selector-modifier
option (seecolumns()
as well) which can be used to modify what rows are selected.Allan
Thanks for the speedy reply allan! So, if I have already applied a search (which I have)
then I can add the code you suggested to get the data instead?
That should do it. If you want it in a plain array append a call to
toArray()
as well.Allan