Filter rows and draw without using search V1.10.15

Filter rows and draw without using search V1.10.15

KaasmanKaasman Posts: 2Questions: 1Answers: 0

Dear community,

I would like to filter rows based on a cell value, while still being able to use the search functionality.

In this example im using table.search(66).draw(); to filter a table. This works but i can't use the search field to further narrow it down.
http://live.datatables.net/cupabuqi/2/edit?js,output

I've tried to use the .filter() function:

$(document).ready( function () {
  var table = $('#myTable').DataTable();

table .column( 3 ) 
     .data()
     .filter( function ( value, index ) { 
         return value == 66 ? true : false; 

} ).draw();

But it doesn't seem to work.

Can anyone point me in the right direction?

Thank you for your time and have a great day!

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,822Questions: 1Answers: 10,127 Site admin
    Answer ✓

    The filter() documentation states:

    This method should not be confused with search() which is used to search for records in the DataTable - i.e. the filter method does not change the rows that are displayed in the DataTable.

    If you want to provide a custom function to search the table you need to use a custom plug-in (currently).

    Allan

  • KaasmanKaasman Posts: 2Questions: 1Answers: 0

    I got it working by using column().search()

This discussion has been closed.