Multiple Tables initialisation complex example
Multiple Tables initialisation complex example
Link to test case:
https://datatables.net/examples/basic_init/multiple_tables.html
Hi, i know that is stupid question... but i didn't find the way how indipendent show 2 tables on one page if i have for each own column and requests...
I see that i initialize table by class but how i add separately the options for each table separately ?
$('table.display').DataTable();
$('#dataTableZakazky').DataTable( {
order: [[0, 'asc']],
pageLength: 10,
fixedHeader: {
header: true,
footer: true
},
data: tableDataZakazky,
columns: [
{ data: 'poradie', title: 'Id'},
{ data: 'firma', title: 'Firma'},
{ data: 'oblast', title: 'Lokalita'},
{ data: 'od', title: 'Od'},
{ data: 'do', title: 'Do'},
{ data: 'os', title: 'Os'},
]
} );
$('#dataTableByty').DataTable( {
order: [[3, 'asc']],
pageLength: 50,
fixedHeader: {
header: true,
footer: true
},
data: tableDataByty,
columns: [
{ data: 'poradie', title: 'Id'},
{ data: 'ubytovatel', title: 'Ubytovateľ'},
{ data: 'oblast', title: 'Oblasť'},
{ data: 'od', title: 'Od'},
{ data: 'do', title: 'Do'},
{ data: 'os', title: 'Kapacita'},
{ data: 'typ', title: 'Typ'},
{ data: 'predajna_cena', title: 'Byt / Cena / Mesiac'},
]
} );
<table id="dataTableZakazky" class="display" width="100%"></table>
<table id="dataTableByty" class="display" width="100%"></table>
Thank you so much
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
This question has an accepted answers - jump to answer
Answers
Remove line 1 from your code snippet. Since you have different configurations you will initialize them separately like you have in the remaining code snippet. I'm guessing you are getting the
Cannot reinitialise DataTable.
error. Removing line 1 will eliminate the error.Kevin
Hi @kthorngren i tried.. but i still have this issue in console
Uncaught TypeError: aoColumns[srcCol] is undefined...
Update: sorry i see that i have problem in other part of my code which change which coloumn will sort the table.. now i solved the issue..
Thank you and sorry, i feel stupid.. but spend 3 hours and i lost hope that i wrote here