javascript - 添加复选框列显示错误:“为第 0 行,第 0 列请求未知参数‘0’”
问题描述
我需要添加一个新列以显示一个复选框以进行进一步的表操作,并且我不断收到“第 0 行第 0 列的请求的未知参数 '0'”。</p>
以前,数据表的代码是这样的(并且没有错误):
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 **/
{...}]
我的尝试是在其他 HTML 文件之前创建一个新<th>
的,并将以下列添加为新的“0”(并将另一列的目标向上移动一个位置)
这确实在每一行上显示了复选框,并启用了多选功能,但它仍然显示提到的错误
{
orderable: false,
className: 'select-checkbox',
targets: 0
}
而且,所需的选择属性如下
select: {
style: 'multi',
selector: 'td:first-child'
}
我正在尝试一些随机的废话,发现添加 adata : null
会使错误消失,但添加了一个新问题(它显示了一个[Object object]
和顶部的复选框)
{
orderable: false,
data : null,
className: 'select-checkbox',
targets: 0
}
我知道由于我缺乏技术知识,这可能(并且可能会)是一个简单的问题,但我自己没有得到任何解决方案。
解决方案
好的,所以,这可能不是最好的解决方案,但只需像这样设置列即可修复错误
{
data : null,
defaultContent : "",
className : 'select-checkbox',
targets : 0
}
推荐阅读
- xaml - TabbedPage 选项卡图标不适用于字体真棒
- java - SpringBoot中如何使用JNDI配置多个数据源?
- c++ - 预处理器错误:cblas.h:没有这样的文件或目录
- php - php 中的 date('G') 函数返回错误的时间?
- r - 如何在合并中删除 .x 和 .y 在 r
- api - 为什么除了 Talend API tester 之外的每个客户端都可以使用此 REST 请求
- android - Android 11 上的新 BlobStoreManager 读写
- awk - awk 在第一次出现字符时拆分
- javascript - 如何在不同的时间制作两个动画?
- typescript - 函数的联合不能传递给泛型函数