Resetting selected rows when filtering
Resetting selected rows when filtering
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
Use
table.rows().deselect()
. Like this:https://live.datatables.net/wobitufe/2/edit
Kevin
The
dt
property of the event object emitted by DataTables events is the API instance, sotable
ande.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