我需要添加一个新列来显示进一步表操作的复选框,并且我不断收到“第 0 行第 0 列请求的未知参数‘0’。”
以前,数据表的代码是这样的(并且没有错误):
tabla = $('#table').DataTable({
/** Default Configuration, it is read from a file but i'll show some of the values in case it is needed for a better understanding of the problem **/
destroy: true,
pagingType : "full_numbers",
paging : true,
lengthChange : true,
lengthMenu : /*Array*/,
pageLength : 25,
serverSide : true,
ordering : false,
searching : true,
processing : true,
deferRender : true,
fnDrawCallback : configDefectoDatatables.fnDrawCallback,
/** AJAX **/
ajax : {
beforeSend: beforeSend,
url : urlAjax,
type : "POST",
timeout : 50000,
error : errorNotificationFunction
},
/** Column Definition **/
columns : [ {
class : "idClass",
data : "id",
defaultContent : "",
targets : 0
}, {
class : "requestClass",
data : "request",
defaultContent : "",
targets : 1
},
/**Some other columns with the same format **/
{...}]
我的尝试是创建一个新的 <th>
在其他列添加到 HTML 文件之前,并将以下列添加为新的“0”(并将另一列的目标向上移动一个位置)
这确实在每一行上显示了复选框,并启用了多重选择功能,但它仍然显示了提到的错误
{
orderable: false,
className: 'select-checkbox',
targets: 0
}
此外,所需的选择属性如下
select: {
style: 'multi',
selector: 'td:first-child'
}
我正在尝试一些随机的废话,发现添加 data : null
使错误消失,但添加了一个新问题(它显示 [Object object]
及其顶部的复选框)
{
orderable: false,
data : null,
className: 'select-checkbox',
targets: 0
}
我知道由于我缺乏技术知识,这可能(并且可能会)是一个简单的问题,但我自己没有得到任何解决方案。
最佳答案
好吧,这可能不是最好的解决方案,但只需像这样设置列就可以修复错误
{
data : null,
defaultContent : "",
className : 'select-checkbox',
targets : 0
}
关于javascript - 添加复选框列显示错误 : "Requested unknown parameter ' 0' for row 0, column 0",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56004841/