Nikelaos Nikelaos - 5 months ago 38
jQuery Question

In DataTables, How to display rows based on a condition?

I'm a beginner with DataTables and I want to display only people, based on the condition a user can select in my

select
.

Example: https://jsfiddle.net/eufvgp7m/1/

I want to display all people who are under the age of 30.
How can I achieve that?

I tried it like this, but I am stuck here:

var table = $('#example').DataTable({
"rowCallback": function(row, data, index){
if (data[3] < 30) {
//code
}
}
});

Answer

Wouldn't this work?

var table = $('#example').DataTable({
   "rowCallback": function(row, data, index){
      if (data[3] >= 30) {
         jQuery(row).hide();
      }
   }
});