Resetting selected rows when filtering

Resetting selected rows when filtering

ja_hernja_hern Posts: 2Questions: 1Answers: 0
edited August 15 in Free community support

Link to test case:

https://live.datatables.net/yipixaro/2/

Debugger code (debug.datatables.net):
ihewoq
Error messages shown:
Description of problem:
Is this the preferred way of resetting select when using Select and SearchPanes on the same table?

` table.on('search.dt', (e) => e.dt.rows().deselect());`

Not included in test case, but issue seen when buttons that are available for actions on selected row(s) are still active if current filter shows no matching records found, or the previously selected row(s) are not included in new filtered results. Adding in the rows().deselect() fixes the issue. Comment it out and the live test case will show same issue with the "rows selected" summary

Answers

  • kthorngrenkthorngren Posts: 21,325Questions: 26Answers: 4,949

    Use table.rows().deselect(). Like this:
    https://live.datatables.net/wobitufe/2/edit

    Kevin

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    The dt property of the event object emitted by DataTables events is the API instance, so table and e.dt are the same here (different API instances, so they won't ===, but they control the same table).

    I think what you've got there is okay. It will deselect all rows in the table whenever a search event happens.

    Allan

Sign In or Register to comment.