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

Muddy WatersMuddy Waters Posts: 19Questions: 6Answers: 0
edited October 2019 in Free community support

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

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954
    Answer ✓

    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

  • Muddy WatersMuddy Waters Posts: 19Questions: 6Answers: 0
    edited October 2019

    awesome, thanks so much :)

    $('#table').DataTable().search("value").draw();

This discussion has been closed.