TypeError: nTd is undefined
TypeError: nTd is undefined
saeb
Posts: 1Questions: 1Answers: 0
hi there I made a very simple html page
<html>
<head>
<meta charset="UTF-8"/>
<link rel="stylesheet" type="text/css" href="./datatables.css"/>
<script src="./jquery-3.3.1.js"></script>
<script src="./datatables.js"></script>
</head>
<body>
<table id="tiretable" class="display" style="width:100%">
<thead>
<tr>
<th>ردیف</th>
<th>نوع</th>
<th>سایز</th>
<th>تعداد</th>
<th>ویرایش</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>barez</td>
<td>13*65*165</td>
<td>0</td>
</tr>
<tr>
<td>2</td>
<td>barez</td>
<td>13*60*175</td>
<td>0</td>
</tr>
<tr>
<td>3</td>
<td>barez</td>
<td>13*70*175</td>
<td>0</td>
</tr>
<tr>
<td>4</td>
<td>barez</td>
<td>14*60*185</td>
<td>0</td>
</tr>
<tr>
<td>5</td>
<td>barez</td>
<td>14*65*185</td>
<td>0</td>
</tr>
<tr>
<td>6</td>
<td>barez</td>
<td>15*65*185</td>
<td>0</td>
</tr>
<tr>
<td>7</td>
<td>barez</td>
<td>15*60*185</td>
<td>0</td>
</tr>
<tr>
<td>8</td>
<td>barez</td>
<td>14*60*205</td>
<td>0</td>
</tr>
<tr>
<td>9</td>
<td>barez</td>
<td>15*60*205</td>
<td>0</td>
</tr>
<tr>
<td>26</td>
<td>kavirtire</td>
<td>14*60*205</td>
<td>0</td>
</tr>
<tr>
<td>27</td>
<td>kavirtire</td>
<td>15*60*205</td>
<td>0</td>
</tr>
<tr>
<td>109</td>
<td>kavirtire</td>
<td>15*60*185</td>
<td>5</td>
</tr>
<tr>
</tr>
</tbody>
<tfoot>
<tr>
<th>ردیف</th>
<th>مدل</th>
<th>سایز</th>
<th>موجودی</th>
<th>ویرایش</th>
</tr>
</tfoot>
</table>
<script>
$(document).ready(function() {
$('#tiretable').DataTable();
} );
</script>
</body>
I have source of libraries
saeb@PublicRelation ~/PhpstormProjects/limit/styles tree
.
├── DataTables-1.10.18
│ ├── css
│ │ ├── dataTables.bootstrap4.css
│ │ ├── dataTables.bootstrap4.min.css
│ │ ├── dataTables.bootstrap.css
│ │ ├── dataTables.bootstrap.min.css
│ │ ├── dataTables.foundation.css
│ │ ├── dataTables.foundation.min.css
│ │ ├── dataTables.jqueryui.css
│ │ ├── dataTables.jqueryui.min.css
│ │ ├── dataTables.semanticui.css
│ │ ├── dataTables.semanticui.min.css
│ │ ├── jquery.dataTables.css
│ │ └── jquery.dataTables.min.css
│ ├── images
│ │ ├── sort_asc_disabled.png
│ │ ├── sort_asc.png
│ │ ├── sort_both.png
│ │ ├── sort_desc_disabled.png
│ │ └── sort_desc.png
│ └── js
│ ├── dataTables.bootstrap4.js
│ ├── dataTables.bootstrap4.min.js
│ ├── dataTables.bootstrap.js
│ ├── dataTables.bootstrap.min.js
│ ├── dataTables.foundation.js
│ ├── dataTables.foundation.min.js
│ ├── dataTables.jqueryui.js
│ ├── dataTables.jqueryui.min.js
│ ├── dataTables.semanticui.js
│ ├── dataTables.semanticui.min.js
│ ├── jquery.dataTables.js
│ └── jquery.dataTables.min.js
├── datatables.css
├── datatables.js
├── datatables.min.css
├── datatables.min.js
├── jquery-3.3.1.js
├── test.html
└── test.html~
but I got this error:
jQuery.Deferred exception: nTd is undefined _fnCreateTr@file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:3118:6
_fnAddData@file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:2435:4
_fnAddTr/<@file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:2463:11
map/<@file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:194:11
map@file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:443:13
map@file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:193:26
_fnAddTr@file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:2461:10
loadedInit@file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:1293:6
DataTable/<@file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:1318:5
each@file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:354:10
each@file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:189:10
DataTable@file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:881:3
$.fn.DataTable@file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:15135:18
@file:///home/saeb/PhpstormProjects/limit/styles/test.html:225:25
mightThrow@file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:3534:21
resolve/</process<@file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:3602:12
undefined
ypeError: nTd is undefined[Learn More] datatables.js:3118:6
_fnCreateTr
file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:3118:6
_fnAddData
file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:2435:4
_fnAddTr/<
file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:2463:11
map/<
file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:194:11
map
file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:443:13
map
file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:193:26
_fnAddTr
file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:2461:10
loadedInit
file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:1293:6
DataTable/<
file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:1318:5
each
file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:354:10
each
file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:189:10
DataTable
file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:881:3
$.fn.DataTable
file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:15135:18
<anonymous>
file:///home/saeb/PhpstormProjects/limit/styles/test.html:225:25
mightThrow
file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:3534:21
resolve/</process<
file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:3602:12
This discussion has been closed.
Answers
You've got 5 cells per row in the header, but only 4 in the table. That mismatch is what is causing the issue.
Allan