Initialize DataTable error
Initialize DataTable error
lynn0402
Posts: 1Questions: 1Answers: 0
I cannot initialize DataTable $('#mainTable').DataTable() and got this bug
dataTables.js:3952 Uncaught (in promise) TypeError: Cannot set properties of undefined (setting '0')
this is my table structure and its tbody
<table class="table table-striped table-bordered" id="mainTable">
<thead class="table-header">
<tr>
<th data-column="Name" rowspan="3">Name ▲</th>
<th data-column="Phone" rowspan="3">Phone Number ▲</th>
<th data-column="Email" rowspan="3">Email ▲</th>
<th data-column="Address" rowspan="3">Address</th>
<th data-column="Order" colspan="2">Order details </th>
<th data-column="Change" rowspan="3">Change</th>
</tr>
<tr>
<th data-column="Brand" rowspan="1">Vehicle's brand</th>
<th data-column="License" rowspan="1">Vehicle's license number</th>
</tr>
</thead>
<tbody id="myTable">
<tr>
<td rowspan="2">John Doe</td>
<td rowspan="2">123-456-7890</td>
<td rowspan="2">john.doe@example.com</td>
<td rowspan="2">123 Main St, Cityville, USA</td>
<td rowspan="1">Toyota</td>
<td rowspan="1">ABC123</td>
<td>
<!-- Change button -->
</td>
</tr>
<tr>
<td rowspan="1">Honda</td>
<td rowspan="1">ABC1234</td>
<td>
<!-- Change button -->
</td>
</tr>
<tr>
<td rowspan="1">Jane Smith</td>
<td rowspan="1">987-654-3210</td>
<td rowspan="1">jane.smith@example.com</td>
<td rowspan="1">456 Elm St, Townsville, USA</td>
<td rowspan="1">Ford</td>
<td rowspan="1">DEF456</td>
<td>
<!-- Change button -->
</td>
</tr>
</tbody>
</table>
Answers
Datatables doesn't support
colspan
androwspan
in thetbody
. See the HTML requirements for details.Kevin
I am facing same issu
Please link to a test case showing the issue.
Allan