Multi-table search

Multi-table search

brilangbrilang Posts: 22Questions: 2Answers: 1

I have two DataTables on the same page. Both are fully functional. One needs to have more columns that the other and I there are business reasons I cannot combine them in a single table. I want to be able to search both tables by typing in the DataTables search box for either table. How can I make this happen? Both tables have the same class.

I can think of two possibilities for a combined search:

  1. Add a function to monitor keyup events and copy the text from one search box to the other to trigger the default search behaviour.
  2. Create an external search field, hide the DataTables default search field, and write a function to trigger the API search on both tables simultaneously.

Which would work better? What if I add more tables to this page in the future (a distinct possibility)?

Answers

This discussion has been closed.