我面临与数据表相关的问题。我有大量记录(45,000 +)。所以我使用带有“服务器端”编码的数据表。
问题是这样的,它在下面的代码中显示以下错误是:
错误:
Uncaught TypeError: Cannot set property 'nTf' of undefined
// allows cells to be used for multiple columns using colspan
if ( tfoot !== null ) {
var cells = oSettings.aoFooter[0];
for ( i=0, ien=cells.length ; i<ien ; i++ ) {
column = columns[i];
column.nTf = cells[i].cell;
if ( column.sClass ) {
$(column.nTf).addClass( column.sClass );
}
我为此使用的 JavaScript 代码是:
$(document).ready(function() {
$('#authorsdatatab').dataTable( {
"bPaginate": true,
"processing": true,
"serverSide": true,
"sAjaxSource": "../assets/common/authorsServerSide.php",
});
});
我在服务器端脚本中用于显示列的数据是:
$aColumns = array( 'a_ID', 'a_name', 'a_birth', 'a_death' );
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "a_ID";
/* DB table to use */
$sTable = "authors";
最佳答案
如果其他人遇到此问题,我发现如果您执行以下操作,就会发生这种情况:
- 使用服务器端处理
- 在您的 HTML 中指定脚
- 在您的 DataTables Javascript 设置中定义一个列数组,该数组不包含脚注中每个单元格的一个列定义
解决方案是确保 Javascript 中的列定义与 HTML 中的实际单元格数相匹配。此问题仍然与新的 DataTables API 相关。
关于php - 数据表页脚错误 : Uncaught TypeError: Cannot set property 'nTf' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24604470/