我一直试图让数据表正常工作,但我不知道我的设置中缺少什么。我花了很多时间修补和谷歌搜索,我希望这是一个西米普尔,我想知道这里有人能够发现。
提前致谢。
错误讯息:
Uncaught TypeError: Cannot read property '_setter' of undefined
at cellProcess (jquery.dataTables.js:1607)
at _fnGetRowElements (jquery.dataTables.js:1628)
at HTMLTableElement.<anonymous> (jquery.dataTables.js:6419)
at Function.each (jquery-2.2.3.min.js:2)
at n.fn.init.each (jquery-2.2.3.min.js:2)
at n.fn.init.DataTable [as dataTable] (jquery.dataTables.js:6092)
at n.fn.init.$.fn.DataTable (jquery.dataTables.js:14775)
at HTMLDocument.<anonymous> ((index):573)
at i (jquery-2.2.3.min.js:2)
at Object.fireWith [as resolveWith] (jquery-2.2.3.min.js:2)
我的JS:
<script>
$(function() {
$("#people").DataTable({
"iDisplayLength": 25,
"processing": true,
"serverSide": true,
"ajax": 'http://example.com/datatables-people',
"columns": [
{ data: 'firstname', defaultContent: '' },
{ data: 'lastname', defaultContent: '' },
{ data: 'userid', defaultContent: '' },
{ data: 'title', defaultContent: '' },
{ data: 'FK_department', defaultContent: '' },
{ data: 'pagerid', defaultContent: '' },
{ data: 'FK_authcode', defaultContent: '' },
{ data: 'roomnumber', defaultContent: '' },
{ data: 'pubroomnumber', defaultContent: '' }
]
});
});
</script>
表格的几个示例列:
<table id="people" class="table table-bordered table-striped dataTable">
<thead>
<tr>
<th>Given Name</th>
<th>Surname</th>
<th>Extension</th>
<th>PDM ID</th>
<th>Title</th>
<th>Department</th>
<th>Pager</th>
<th>Authcode</th>
<th>Room Number</th>
<th>Pub Room Number</th>
</tr>
</thead>
<tbody>
<tr>
<td>Sample</td>
<td>Person</td>
<td>Ext</td>
<td>512304</td>
<td>Physiotherapist</td>
<td>Physiotherapy</td>
<td>13780</td>
<td>0</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Sample</td>
<td>Person</td>
<td>Ext</td>
<td>518435</td>
<td>Staffing Clerk</td>
<td>Customer Support Centre</td>
<td>0</td>
<td>0</td>
<td>E1-501</td>
<td>E1-501</td>
</tr>
<tr>
<td>Sample</td>
<td>Person</td>
<td>Ext</td>
<td>523385</td>
<td>Coordinator</td>
<td>Birthing Centre</td>
<td>15288</td>
<td>0</td>
<td>B4-125</td>
<td>B4-125</td>
</tr> ....
答案 0 :(得分:3)
You have missed a column for Extension
<script>
$(function() {
$("#people").DataTable({
"iDisplayLength": 25,
"processing": true,
"serverSide": true,
"ajax": 'http://example.com/datatables-people',
"columns": [
{ data: 'firstname', defaultContent: '' },
{ data: 'lastname', defaultContent: '' },
{ data: 'extension', defaultContent: '' },
{ data: 'userid', defaultContent: '' },
{ data: 'title', defaultContent: '' },
{ data: 'FK_department', defaultContent: '' },
{ data: 'pagerid', defaultContent: '' },
{ data: 'FK_authcode', defaultContent: '' },
{ data: 'roomnumber', defaultContent: '' },
{ data: 'pubroomnumber', defaultContent: '' }
]
});
});
</script>