Using more than one Datatable with Subtable(s)
Using more than one Datatable with Subtable(s)
Hi Forum,
my name is Dominik and I am new on datatables.net. I have read several threads on several forums, how to init multiple datatables, but at this moment I have no idea, how to init 2 maintables with minimum 1 subtable. Let me scribble the situation:
upper Page: 1 Datatable with 1 SubDatatable
bottom Page: 1 Datatable with 2 SubDatatables
The Problem follows after the Code...
This is my HTML:
<section class="content container-fluid">
<h2>Normale Bestellungen</h2>
<table id="maintable" class="display" style="width:100%">
<thead>
<tr>
<th></th>
<th>ID</th>
<th>Status</th>
<th>B-Nummer</th>
<th>Beschreibung</th>
<th>Bestelldatum</th>
<th>Lieferdatum/-typ</th>
<th>Lieferadresse</th>
<th>Aktionen</th>
</tr>
</thead>
</table>
<h2>Sonstige Bestellungen</h2>
<table id="maintable_orders" class="display" style="width:100%">
<thead>
<tr>
<th>V</th>
<th>D</th>
<th>ID</th>
<th>Datum</th>
<th>Typ</th>
<th>Status</th>
<th>Produktionsnummer</th>
<th>Werbetermin (KW)</th>
<th>Liefertermin (KW)</th>
<th>Notiz</th>
<th>Aktionen</th>
</tr>
</thead>
</table>
</section>
As you can see at those 3 Comments within the code, everything works except the subtable of the first maintable. The ajax-call is never been initialized, so I don´t get a needed parameter called "marketplace_order_id", thats essential for the non-working subtable.
My comments are on line 9,49 and 52 of the js-textarea.
I hope this is understandable, if I could give additional information please ask.
Thx and regards, Dominik
Replies
I need to post the js seperately:
Here´s my JS:
I'm guessing the problem is due to this error you are getting?
var subtable_id = row.data()['marketplace_order_id']; //Uncaught TypeError: Cannot read property 'marketplace_order_id' of undefined
I think the problem is you are using the variable
table
for both tables:var table = $('#maintable').DataTable({
and
var table = $("#maintable_orders").DataTable({
I need to use different variables.
Kevin
Hi Kevin,
you´ re absolutely right - That saved my day. Tanks very much.
regards
Dominik