我对Datatables
有意见。我还检查了this link,但没有产生任何结果。我已经包含了将数据直接解析到DOM中的所有先决条件。请帮助我解决这个问题。
脚本
$(document).ready(function() {
$('.viewCentricPage .teamCentric').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bPaginate": false,
"bFilter": true,
"bSort": true,
"aaSorting": [
[1, "asc"]
],
"aoColumnDefs": [{
"bSortable": false,
"aTargets": [0]
}, {
"bSortable": true,
"aTargets": [1]
}, {
"bSortable": false,
"aTargets": [2]
}],
});
});
发布于 2014-09-22 08:33:47
仅供参考dataTables需要格式正确的表。它必须包含<thead>
和<tbody>
标记,否则将抛出此错误。还要检查以确保包括标题行在内的所有行都有相同的列数。
以下代码将抛出错误(无<thead>
和<tbody>
标记)
<table id="sample-table">
<tr>
<th>title-1</th>
<th>title-2</th>
</tr>
<tr>
<td>data-1</td>
<td>data-2</td>
</tr>
</table>
下面的代码也会抛出错误(列数不相等)
<table id="sample-table">
<thead>
<tr>
<th>title-1</th>
<th>title-2</th>
</tr>
</thead>
<tbody>
<tr>
<td>data-1</td>
<td>data-2</td>
<td>data-3</td>
</tr>
</tbody>
</table>
有关更多信息,请访问read more here
发布于 2014-11-08 05:47:09
Cannot read property 'fnSetData' of undefined
的常见原因是列数不匹配,如下面的错误代码所示:
<thead> <!-- thead required -->
<tr> <!-- tr required -->
<th>Rep</th> <!-- td instead of th will also work -->
<th>Titel</th>
<!-- th missing here -->
</tr>
</thead>
<tbody>
<tr>
<td>Rep</td>
<td>Titel</td>
<td>Missing corresponding th</td>
</tr>
</tbody>
虽然下面的代码使用每个<th>
<td>
的one (列数必须匹配)可以工作:
<thead>
<tr>
<th>Rep</th> <!-- 1st column -->
<th>Titel</th> <!-- 2nd column -->
<th>Added th</th> <!-- 3rd column; th added here -->
</tr>
</thead>
<tbody>
<tr>
<td>Rep</td> <!-- 1st column -->
<td>Titel</td> <!-- 2nd column -->
<td>th now present</td> <!-- 3rd column -->
</tr>
</tbody>
如果使用结构良好的头部,但没有第二行,则也会出现此错误。
对于有7列的表,以下代码不起作用,并且我们在javascript控制台中看到"Cannot read property 'mData‘of undefined“:
<thead>
<tr>
<th>Rep</th>
<th>Titel</th>
<th colspan="5">Download</th>
</tr>
</thead>
在此过程中:
<thead>
<tr>
<th rowspan="2">Rep</th>
<th rowspan="2">Titel</th>
<th colspan="5">Download</th>
</tr>
<tr>
<th>pdf</th>
<th>nwc</th>
<th>nwctxt</th>
<th>mid</th>
<th>xml</th>
</tr>
</thead>
发布于 2019-05-20 14:26:03
拥有相同数量的<th>
和<td>
的<thead>
和<tbody>
解决了我的问题。
https://stackoverflow.com/questions/25377637
复制相似问题