multiple table on same page with keytable?
multiple table on same page with keytable?
romanseko
Posts: 5Questions: 1Answers: 0
Hello,
is possible use together multible datatables on same page with keytable extension?. I need to work keys on focused table. Thanks
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
It works here:
http://live.datatables.net/sihadigi/1/edit
Are you having issues with KeyTable?
Kevin
working with cell select, I need select row. I tried to handle with select plugin but with no succsess
Its not clear to me what the issue is. I updated the example to include select. The first table selects rows and the second selects cells:
http://live.datatables.net/sihadigi/1/edit
Maybe you can update the examples to show the issue you are having.
Kevin
Depends on API data I load several tablas on page. Is necessary to call each table as new instance? or can share same preferences? this is my current code
http://live.datatables.net/tatixace/1/edit?html,js,output
Thanks for the test case - it helps a lot to understand the issue. I made a couple changes, see if this works as you want:
http://live.datatables.net/gaweheka/1/edit
I don't remember if the
table
variable would contain both Datatables or the last Datatable when initializing them with a single set of init options. It did seem liketable
only referenced the last table since the select event only worked with the second.First I chained the events off the DataTable() init method.
Then I changed this in the
key-focus
event:table.row(cell.index().row).select();
To this:
datatable.row(cell.index().row).select();
Last I commented out the
select
option and added therows().deselect()
to deselect all rows in the table before selecting the row clicked on. Otherwise there seems to be a race condition which doesn't allow the row to be selected.But all of this seems overkill when you can just use the
select
option you have configured without using thekey-focus
event to manipulate the row selection. Here is the example:http://live.datatables.net/gaxenana/1/edit
Hopefully one or the other will help you do what you need.
Kevin
Thank you a lot, this solves most of my problems, the last one is the selected row must be only in active table, is it possible?
Yes, you would use the first example then in the key-focus event use
rows().deselect()
to deselect the rows in all the tables followed by selecting the row clicked on. Here is the updated example:http://live.datatables.net/vamenure/1/edit
Kevin
Great! Thank you a lot