Initialize DataTable error

Initialize DataTable error

lynn0402lynn0402 Posts: 1Questions: 1Answers: 0
edited May 8 in Free community support

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 &#9650</th>
            <th data-column="Phone" rowspan="3">Phone Number &#9650</th>
            <th data-column="Email" rowspan="3">Email &#9650</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

  • kthorngrenkthorngren Posts: 21,391Questions: 26Answers: 4,961

    Datatables doesn't support colspan and rowspan in the tbody. See the HTML requirements for details.

    Kevin

  • suzensuzen Posts: 7Questions: 3Answers: 0

    I am facing same issu

  • allanallan Posts: 63,602Questions: 1Answers: 10,486 Site admin

    I am facing same issu

    Please link to a test case showing the issue.

    Allan

Sign In or Register to comment.