how to use filter() on a search() result ?
how to use filter() on a search() result ?
mJehanno
Posts: 2Questions: 1Answers: 0
Hi guys,
i'm trying to filter()
the result i get after a search()
:
here is what i'm trying to do -> http://live.datatables.net/qawatoci/2/edit
(i want to display only rows that have an empty 'start date field' for the software engineer only).
assuming that my function isOldEnough() is declared before like this
function isOldEnough(value){
console.log(value);
return value === "";
}
i've tried the following :
$(document).ready( function () {
var table = $('#example').DataTable();
var filtered = table.search("Software Engineer").column(4).data().filter(isOldEnough).draw();
}
$(document).ready( function () {
var table = $('#example').DataTable();
table.search("Software Engineer");
table.column(4).data().filter(isOldEnough).draw();
}
$(document).ready( function () {
var table = $('#example').DataTable();
var newtable = table.search("Software Engineer");
newtable.column(4).data().filter(isOldEnough).draw();
}
If you could give me some tips it'd be nice.
thanks !
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi,
The
filter()
method does not remove rows from the DataTable. As the documentation for it says:Instead it simply filters the results in the API result object.
Currently, if you want to apply a custom function to search a table you need to use a search plug-in.
Allan
Ow, thought it was working like the filter method in native js.
Thanks .
It works exactly like filter in native Javascript - but only on the API result set. Not on the table's contents.
Allan