Add a value to a DataTables filter input box and filter the table
Add a value to a DataTables filter input box and filter the table
Is it possible to add a value to the filter input and filter the table without typing in the input?
I would like to filter an existing table if a condition is met. If the condition is met, a variable will be automatically placed in the filter input and the table is refreshed to show the matching rows, as if a user typed it in.
I have tried variations of things like below but it just replaces the input entirely.
$('#table_filter > label > span.ui.input').text("value");
This question has an accepted answers - jump to answer
Answers
Instead of trying to update the input you should use the
search()
API. It will automatically update the search input with the search term.Kevin
awesome, thanks so much
$('#table').DataTable().search("value").draw();