DatatablesBundle icon indicating copy to clipboard operation
DatatablesBundle copied to clipboard

Filter/search not working with column visibility until page refresh

Open AlanKrygowski opened this issue 7 years ago • 0 comments

There seems to be an issue with using column filtering right after the column itself is appended using Column Visibility.

Steps to reproduce

  1. Open a table with not all (searchable) columns visible
  2. Show the column using the column visibility
  3. 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) {...});

AlanKrygowski avatar Dec 29 '18 17:12 AlanKrygowski