How to Filter and Draw?

How to Filter and Draw?

nenomaznenomaz Posts: 3Questions: 1Answers: 0

Hi!
I need to filter records of a table with the metod .filter() and next redraw the table with draw(). How to do it?

DataTables v. 1.10.3

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    If you mean "Filter the table based on a custom input and redraw:" just look at the docs:

    https://datatables.net/reference/api/draw

  • nenomaznenomaz Posts: 3Questions: 1Answers: 0

    I need a sequence like this that works:

    table
    .columns()
    .filter(function(val, index){
       // Here my filter rules
    })
    .draw()
    
  • allanallan Posts: 63,747Questions: 1Answers: 10,509 Site admin

    filter() will filter the result set - not the data contained in the table. The documentation specifically states this:

    This method should not be confused with search() which is used to search for records in the DataTable.

    The only way to use a custom function to apply a search to a table at this time is to use a search plug-in.

    The ability to use a custom function in search() will be introduced in the next major version of DataTables.

    Allan

  • nenomaznenomaz Posts: 3Questions: 1Answers: 0

    Thank you Allan, I'll try it :-)

This discussion has been closed.