我使用jquery创建了一个数据表,如下所示: 该表有6列。第一列是复选框,而最后一列是文本框。
$('#multiple-account-table').dataTable({
"data": [
{"accountNumber":"131-202553701","name":"Account 1","dueDate":"10/19/2016","statementBalance":"34.60"},
{"accountNumber":"131-202553702","name":"Account 2","dueDate":"10/19/2015","statementBalance":"14.50"},
{"accountNumber":"131-202553703","name":"Account 3","dueDate":"10/19/2015","statementBalance":"15.50"}
],
"dom": 'it',
"pageLength": 8,
"language": {
"info": "_END_ of _TOTAL_ selected",
"emptyTable": "No records are available",
},
"columns": [
{"data": null},
{"data": "accountNumber"},
{"data": "name"},
{"data": "dueDate"},
{"data": "statementBalance"},
{"data": null}
],
"columnDefs": [
{className: "pad-md-left-p-10 pad-top-bottom-p-10 white-active-bg mouse-link", "targets": [0,1,2,3,4,5]},
{
'targets': 0,
'orderable': false,
'render': function(data, type, full, meta) {
return '<input type="checkbox" name="payment-checkbox" class="multi-checkbox"/>';
}
},
{
'targets': 3,
"fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
$(nTd).text(date);
}
},
{
'targets': 4,
'orderable': false,
"fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
$(nTd).html('$'+sData);
}
},
{
'targets': 5,
'searchable':false,
'orderable':false,
"fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
$(nTd).html('<span class="bold">Payment Amount</span> <span class="dollar-font-xs">$<input type="number" id="payement-textbox-xs'+index_xs+'" class="payment-xs" min="0" max="100000" step="any" maxlength="9" value="" name="payment-textbox" placeholder="--"/></span>');
}
}
],
"aaSorting": [[3, 'desc'], , [4,'asc'] ],
}); //End of datatable function
我收到此错误:未捕获的TypeError:无法读取未定义的属性“0”。有什么建议吗?
答案 0 :(得分:1)
检查此行,您的代码是否正确?
"aaSorting": [[3, 'desc'], , [4,'asc'] ],