DatatablesBundle
DatatablesBundle copied to clipboard
Filter/search not working with column visibility until page refresh
There seems to be an issue with using column filtering right after the column itself is appended using Column Visibility.
Steps to reproduce
- Open a table with not all (searchable) columns visible
- Show the column using the column visibility
- Try searching in the new column header
What happens?
Nothing :( As if no listener was applied. After page reload, the input works as should.
Looking into it, the problem occurs due to usage of static binding in this file, lines 40 & 42: https://github.com/stwe/DatatablesBundle/blob/master/Resources/views/datatable/search.js.twig
The solution I found, was using dynamic bindings on the listeners:
$(selector).find("tr").on("keyup change", 'input.sg-datatables-individual-filtering', search);
$(selector).find("tr").on("keyup change", 'select.sg-datatables-individual-filtering', function(event) {...});