I am getting this error:
Uncaught TypeError: Cannot set property '_DT_CellIndex' of undefined
I searched the web and found that it usually occurs when the count of th mismatches the count of td.
But I don't think that is causing the problem. See the table defination below :
$(document).ready(function() {
$('#chat').DataTable({
responsive: true,
"bLengthChange": false,
});
});
<script src=".1.1/jquery.min.js"></script>
<script src="//cdn.datatables/1.10.16/js/jquery.dataTables.min.js"></script>
<link href="//cdn.datatables/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet"/>
<table class="table table-striped table-bordered" id="chat">
<thead>
<tr>
<th>From</th>
<th>To</th>
<th>Message</th>
<th>Time of Messgae</th>
</tr>
</thead>
<tbody>
<tr>
<td>jhon</td>
<td>rylie</td>
<td>
<message xmlns:cli="jabber:client" to="[email protected]" cli:subject="TEXT MESSAGE" cli:lang="en" type="chat" id="jhon_1523607791051" from="[email protected]/bizRTC">
<body>Hey Rylie</body>
<request xmlns="urn:xmpp:receipts"></request>
</message>
</td>
<td>13-04-18 08:23:11</td>
</tr>
<tr>
</tr>
<tr>
<td>rylie</td>
<td>jhon</td>
<td>
<message xmlns:cli="jabber:client" to="[email protected]" cli:subject="TEXT MESSAGE" cli:lang="en" type="chat" id="rylie_1523607808352" from="[email protected]/bizRTC">
<body>Hey Jhon</body>
<request xmlns="urn:xmpp:receipts"></request>
</message>
</td>
<td>13-04-18 08:23:29</td>
</tr>
<tr>
<td>rylie</td>
<td>rajanjadav</td>
<td><i class="material-icons">play_circle_filled</i> PTT Message</td>
<td>13-04-18 08:36:21</td>
</tr>
<tr>
</tr>
<tr>
<td>rylie</td>
<td>jhon</td>
<td>
<message xmlns:cli="jabber:client" to="[email protected]" cli:subject="TEXT MESSAGE" cli:lang="en" type="chat" id="rylie_1523608843382" from="[email protected]/bizRTC">
<body>what are you doing</body>
<request xmlns="urn:xmpp:receipts"></request>
</message>
</td>
<td>13-04-18 08:40:43</td>
</tr>
<tr>
<td>jhon</td>
<td>rylie</td>
<td>
<message xmlns:cli="jabber:client" to="[email protected]" cli:subject="TEXT MESSAGE" cli:lang="en" type="chat" id="jhon_1523608972383" from="[email protected]/bizRTC">
<body>Nothing much</body>
<request xmlns="urn:xmpp:receipts"></request>
</message>
</td>
<td>13-04-18 08:42:52</td>
</tr>
<tr>
</tr>
<tr>
<td>jhon</td>
<td>rylie</td>
<td>
<message xmlns:cli="jabber:client" to="[email protected]" cli:subject="TEXT MESSAGE" cli:lang="en" type="chat" id="jhon_1523609330813" from="[email protected]/bizRTC">
<body>This is for jqyeur</body>
<request xmlns="urn:xmpp:receipts"></request>
</message>
</td>
<td>13-04-18 08:48:50</td>
</tr>
<tr>
</tr>
<tr>
<td>rylie</td>
<td>jhon</td>
<td>
<message xmlns:cli="jabber:client" to="[email protected]" cli:subject="TEXT MESSAGE" cli:lang="en" type="chat" id="rylie_1523609341479" from="[email protected]/bizRTC">
<body>okay got it msg</body>
<request xmlns="urn:xmpp:receipts"></request>
</message>
</td>
<td>13-04-18 08:49:01</td>
</tr>
<tr>
<td>jhon</td>
<td>rylie</td>
<td>
<message xmlns:cli="jabber:client" to="[email protected]" cli:subject="TEXT MESSAGE" cli:lang="en" type="chat" id="jhon_1523611389535" from="[email protected]/bizRTC">
<body>Say else what are you doing</body>
<request xmlns="urn:xmpp:receipts"></request>
</message>
</td>
<td>13-04-18 09:23:09</td>
</tr>
<tr>
</tr>
<tr>
<td>rylie</td>
<td>jhon</td>
<td>
<message xmlns:cli="jabber:client" to="[email protected]" cli:subject="TEXT MESSAGE" cli:lang="en" type="chat" id="rylie_1523611415081" from="[email protected]/bizRTC">
<body>nothing much just coding right now</body>
<request xmlns="urn:xmpp:receipts"></request>
</message>
</td>
<td>13-04-18 09:23:35</td>
</tr>
<tr>
<td>jhon</td>
<td>rylie</td>
<td>
<message xmlns:cli="jabber:client" to="[email protected]" cli:subject="TEXT MESSAGE" cli:lang="en" type="chat" id="jhon_1523611468570" from="[email protected]/bizRTC">
<body>What's ur password</body>
<request xmlns="urn:xmpp:receipts"></request>
</message>
</td>
<td>13-04-18 09:24:28</td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td>jhon</td>
<td>rylie</td>
<td><i class="material-icons">play_circle_filled</i> PTT Message</td>
<td>13-04-18 09:27:18</td>
</tr>
<tr>
</tr>
<tr>
<td>jhon</td>
<td>rajanjadav</td>
<td>
<message xmlns:cli="jabber:client" to="[email protected]/bizRTC" cli:subject="TEXT MESSAGE" cli:lang="en" type="groupchat" id="jhon_1523611651354" from="[email protected]/jhon__umobilityptt.7600556046">
<body>This message is sent in bizrtc group</body>
<request xmlns="urn:xmpp:receipts"></request>
</message>
</td>
<td>13-04-18 09:27:31</td>
</tr>
<tr>
<td>rylie</td>
<td>rajanjadav</td>
<td>
<message xmlns:cli="jabber:client" to="[email protected]/bizRTC" cli:subject="TEXT MESSAGE" cli:lang="en" type="groupchat" id="rylie_1523613602613" from="[email protected]/rylie__umobilityptt.7600556046">
<body>what happened in the meeting with Alliance</body>
<request xmlns="urn:xmpp:receipts"></request>
</message>
</td>
<td>13-04-18 10:00:03</td>
</tr>
</tr>
</tbody>
</table>
What can be the possible solution for this ?
I am getting this error:
Uncaught TypeError: Cannot set property '_DT_CellIndex' of undefined
I searched the web and found that it usually occurs when the count of th mismatches the count of td.
But I don't think that is causing the problem. See the table defination below :
$(document).ready(function() {
$('#chat').DataTable({
responsive: true,
"bLengthChange": false,
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<link href="//cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet"/>
<table class="table table-striped table-bordered" id="chat">
<thead>
<tr>
<th>From</th>
<th>To</th>
<th>Message</th>
<th>Time of Messgae</th>
</tr>
</thead>
<tbody>
<tr>
<td>jhon</td>
<td>rylie</td>
<td>
<message xmlns:cli="jabber:client" to="[email protected]" cli:subject="TEXT MESSAGE" cli:lang="en" type="chat" id="jhon_1523607791051" from="[email protected]/bizRTC">
<body>Hey Rylie</body>
<request xmlns="urn:xmpp:receipts"></request>
</message>
</td>
<td>13-04-18 08:23:11</td>
</tr>
<tr>
</tr>
<tr>
<td>rylie</td>
<td>jhon</td>
<td>
<message xmlns:cli="jabber:client" to="[email protected]" cli:subject="TEXT MESSAGE" cli:lang="en" type="chat" id="rylie_1523607808352" from="[email protected]/bizRTC">
<body>Hey Jhon</body>
<request xmlns="urn:xmpp:receipts"></request>
</message>
</td>
<td>13-04-18 08:23:29</td>
</tr>
<tr>
<td>rylie</td>
<td>rajanjadav</td>
<td><i class="material-icons">play_circle_filled</i> PTT Message</td>
<td>13-04-18 08:36:21</td>
</tr>
<tr>
</tr>
<tr>
<td>rylie</td>
<td>jhon</td>
<td>
<message xmlns:cli="jabber:client" to="[email protected]" cli:subject="TEXT MESSAGE" cli:lang="en" type="chat" id="rylie_1523608843382" from="[email protected]/bizRTC">
<body>what are you doing</body>
<request xmlns="urn:xmpp:receipts"></request>
</message>
</td>
<td>13-04-18 08:40:43</td>
</tr>
<tr>
<td>jhon</td>
<td>rylie</td>
<td>
<message xmlns:cli="jabber:client" to="[email protected]" cli:subject="TEXT MESSAGE" cli:lang="en" type="chat" id="jhon_1523608972383" from="[email protected]/bizRTC">
<body>Nothing much</body>
<request xmlns="urn:xmpp:receipts"></request>
</message>
</td>
<td>13-04-18 08:42:52</td>
</tr>
<tr>
</tr>
<tr>
<td>jhon</td>
<td>rylie</td>
<td>
<message xmlns:cli="jabber:client" to="[email protected]" cli:subject="TEXT MESSAGE" cli:lang="en" type="chat" id="jhon_1523609330813" from="[email protected]/bizRTC">
<body>This is for jqyeur</body>
<request xmlns="urn:xmpp:receipts"></request>
</message>
</td>
<td>13-04-18 08:48:50</td>
</tr>
<tr>
</tr>
<tr>
<td>rylie</td>
<td>jhon</td>
<td>
<message xmlns:cli="jabber:client" to="[email protected]" cli:subject="TEXT MESSAGE" cli:lang="en" type="chat" id="rylie_1523609341479" from="[email protected]/bizRTC">
<body>okay got it msg</body>
<request xmlns="urn:xmpp:receipts"></request>
</message>
</td>
<td>13-04-18 08:49:01</td>
</tr>
<tr>
<td>jhon</td>
<td>rylie</td>
<td>
<message xmlns:cli="jabber:client" to="[email protected]" cli:subject="TEXT MESSAGE" cli:lang="en" type="chat" id="jhon_1523611389535" from="[email protected]/bizRTC">
<body>Say else what are you doing</body>
<request xmlns="urn:xmpp:receipts"></request>
</message>
</td>
<td>13-04-18 09:23:09</td>
</tr>
<tr>
</tr>
<tr>
<td>rylie</td>
<td>jhon</td>
<td>
<message xmlns:cli="jabber:client" to="[email protected]" cli:subject="TEXT MESSAGE" cli:lang="en" type="chat" id="rylie_1523611415081" from="[email protected]/bizRTC">
<body>nothing much just coding right now</body>
<request xmlns="urn:xmpp:receipts"></request>
</message>
</td>
<td>13-04-18 09:23:35</td>
</tr>
<tr>
<td>jhon</td>
<td>rylie</td>
<td>
<message xmlns:cli="jabber:client" to="[email protected]" cli:subject="TEXT MESSAGE" cli:lang="en" type="chat" id="jhon_1523611468570" from="[email protected]/bizRTC">
<body>What's ur password</body>
<request xmlns="urn:xmpp:receipts"></request>
</message>
</td>
<td>13-04-18 09:24:28</td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td>jhon</td>
<td>rylie</td>
<td><i class="material-icons">play_circle_filled</i> PTT Message</td>
<td>13-04-18 09:27:18</td>
</tr>
<tr>
</tr>
<tr>
<td>jhon</td>
<td>rajanjadav</td>
<td>
<message xmlns:cli="jabber:client" to="[email protected]/bizRTC" cli:subject="TEXT MESSAGE" cli:lang="en" type="groupchat" id="jhon_1523611651354" from="[email protected]/jhon__umobilityptt.7600556046">
<body>This message is sent in bizrtc group</body>
<request xmlns="urn:xmpp:receipts"></request>
</message>
</td>
<td>13-04-18 09:27:31</td>
</tr>
<tr>
<td>rylie</td>
<td>rajanjadav</td>
<td>
<message xmlns:cli="jabber:client" to="[email protected]/bizRTC" cli:subject="TEXT MESSAGE" cli:lang="en" type="groupchat" id="rylie_1523613602613" from="[email protected]/rylie__umobilityptt.7600556046">
<body>what happened in the meeting with Alliance</body>
<request xmlns="urn:xmpp:receipts"></request>
</message>
</td>
<td>13-04-18 10:00:03</td>
</tr>
</tr>
</tbody>
</table>
What can be the possible solution for this ?
Share Improve this question edited Dec 3, 2021 at 14:25 IGP 15.8k5 gold badges31 silver badges50 bronze badges asked Apr 13, 2018 at 10:34 RajanRajan 2,42510 gold badges55 silver badges113 bronze badges2 Answers
Reset to default 15DataTables expects the table to be populated consistently with each row, with the same number of columns. The cause is the empty elements in your HTML.
<tr>
</tr>
If you remove those empty rows, the error will go.
Just an FYI: datatables also do not play well with colspan. I have a table with 3 cells, but one colspan=3 row and they give the same error.