Searching a column for data that is added after table load.
Searching a column for data that is added after table load.
Hi All!
I've got a problem which I can't seem to resolve. Basically I have a table full of client data and I've got a column to allow the user to save clients as favourites. As you can sort images I've created another column which acts as a flag. When someone clicks on the image icon it change the image to indicate its been flagged and ads "yesfave" to the fave column to allow filtre to favourites. This faves column will eventually be hidden but I have it visible for testing purposes. The text is being added to the column no problem - the issue I have is when i try and apply a search to the column - specifically "yesfave" no entries are shown.
I know i'm doing the search correctly as I use the same search for other filters and it works fine - this is the JS i use:
$('#csvOutput').DataTable().search("yesfave").draw();
I've also tried:
$('#csvOutput').DataTable().column(10).search("yesfave").draw();
but neither work.
For security reasons I can't give any more code as it's confidential.
Any thoughts?
Answers
I managed to resolve the issue now. The data I was entering / amending was writing to the HTML and and not updating the datatable itself.
Changed the write js to:
table.cell(tr, 0).data('<img src="../Images/fave-toggle.png" /> ').draw;
and this draws the new image and content into the datatable which then becomes searchable.