2 table views - Synchronized tables
2 table views - Synchronized tables
robertshawn
Posts: 5Questions: 2Answers: 0
Is it possible to have 2 tables that are controlled by 1 filter set?
I've used FilterMultipleTables from yadcf to do it in this example.
Is there another way to have synchronized tables? Or 2 views of the same table?
Answers
It is possible. This example shows one way to do this:
https://live.datatables.net/jujuqixe/1/edit
First it sets default config options for all tables. Your solution might not need this just made the example easier. It uses
dom
to show only the info element for the second table.The key to this example is to use only the inputs for the first table to drive the second. You can try controlling both tables with inputs from both but it makes the using the Datatables events more complicated as you can easily get into an infinite loop.
The example uses the
search
,order
,page
, andlength
to update the second Datatable. It uses thepage.info()
to get the paging info,order()
to get the current order andsearch()
to get the current search term.When changing the page length or page number it uses
draw()
with thepage
parameter to stay on the same page and not recalculate the sorting and searching.You can also you something like these column search examples:
https://datatables.net/examples/api/multi_filter.html
https://datatables.net/examples/api/multi_filter_select.html
And use
column().search()
with the inputs search term on table 2. This is simulated with the Tiger search button.Kevin
Thank you Kevin. I think this first example is just what I'm looking for. Is it possible to create, or is there an existing table.on function for Search Panes?
Unfortunately no - sorry. Not at this time at least. SearchPanes doesn't expose an API to get or set its current state. Without that, there would be no way to have a single instance of SearchPanes control two tables. Sorry.
Allan