Why filter() function not hiding/showing the row(s)?

Why filter() function not hiding/showing the row(s)?

rannierannie Posts: 6Questions: 2Answers: 0
edited October 2018 in Free community support

I tried this.

dt.rows().data().filter(() => {
  return false
}).draw()

but rows are still visible.

This question has an accepted answers - jump to answer

Answers

  • rannierannie Posts: 6Questions: 2Answers: 0
    edited October 2018

    I want to add a filter form in my data table.
    I want the table to update when the user change the state of filter form.

    just like this javascript array filter.

    rows.filter((row) => {
      return matchInFilterForm(row)
    })
    
  • rannierannie Posts: 6Questions: 2Answers: 0
    edited October 2018

    Any help? Thanks!

  • allanallan Posts: 63,464Questions: 1Answers: 10,466 Site admin
    Answer ✓

    As the filter() documentation says:

    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 search the table and update the display for that search, you need to use search() or a search plug-in method.

    Allan

  • rannierannie Posts: 6Questions: 2Answers: 0
    edited October 2018

    Here is exactly what i want <3 <3 <3

    https://datatables.net/examples/plug-ins/range_filtering

    Thanks for your suggestion Allan!

This discussion has been closed.