Multiple Table Setups
Multiple Table Setups
Hello,
I've been reading through the manual about multiple DataTables on a single page.
I'm using the single declaration method.
var tables = $('.table').DataTable( {
searching: false,
ordering: false,
paging: false, bInfo : false,
select: {
style: 'multi'
}} );
Whilst this works in the fact that both tables on my page are turned into DataTables, it would appear that only the 2nd DataTables is accessible via the tables variable.
I've read through as much information on multiple DataTables as I can find but still can't seem to access both tables from the single variable.
Short of instantiating both tables independently, how can I access both tables?
This question has an accepted answers - jump to answer
Answers
Hi @Dalder ,
This example here should help.
You can access it with
table()
, i.e.tables.table(0)
andtables.table(1)
.Cheers,
Colin
Hi Colin,
Thanks for the example and the response.
I tried your solution with my setup and unfortunately it still doesn't work.
I've created an example here where it still doesn't work, so I imagine I'm doing something wrong!
Any further help you can offer is greatly appreciated.
Thanks,
Dan
Hi Dan,
Yep, something wrong You had the ID the same for both tables, which isn't valid HTML and therefore breaks stuff. If you make them unique, as in here, everything works a treat.
Cheers,
Colin
D'oh!
At one point in time they definitely had separate IDs, must have got a a bit over zealous with the copy and pasting.
Oh well, thanks for pointing out my stupid mistake, all is working as intended.
Dan