How to synchronize search between datatables?

How to synchronize search between datatables?

RuudscornerRuudscorner Posts: 2Questions: 2Answers: 0

Between multiple datatables I want it so that when one writes something in the "Search" box then that search text will be applied on all datatables. I tried this:

    $(".dataTables_filter input").keyup(function () {
        $(".dataTables_filter input").val($(this).val());
    });

The text gets copied to all the datatables, but does not take effect. It also gets cleared when the datatable reloads content.

Answers

  • allanallan Posts: 61,669Questions: 1Answers: 10,096 Site admin

    Use search() rather than writing the value to the input. You could do that - you just need to trigger the change event, but I generally would suggest using the API.

    Allan

  • allanallan Posts: 61,669Questions: 1Answers: 10,096 Site admin

    You probably want to add a check so it doesn't change the value of the input that triggered the search as well!

This discussion has been closed.