Search filter greater than in datatable

Viewed 3669

I'm working with datatables and I need to use search() as follows:

let table = $('#datatable-table').DataTable();
$('#boton-filtrar').click(function (e) {
e.preventDefault();
table
  .column(8)
  .search('> 20') //Here is the cuestion!
  .draw();
  });

That is, create a search filter in column 8 that returns all numbers greater than 20.

Column number 8 contains numerical values.

20 is by way of example, since the value will be given by another input that is already prepared.

I have searched but I have not found anything.

Some help? Thank you.

1 Answers

According to the documentation .search() is actually more of a filter which works with string comparison (either straight or using regular expressions). You want to filter/search based on a numerical comparison.

Have a look at how you can add this custom filtering function at https://datatables.net/examples/plug-ins/range_filtering.html

Related