【发布时间】:2021-07-03 10:47:17
【问题描述】:
表格标题
<thead>
<tr>
<th rowspan="2">Project</th>
<th rowspan="2">Status</th>
<th colspan="2">Features</th>
</tr>
<tr>
<th>Passing</th>
<th>Failing</th>
</tr>
</thead>
JS 代码
$('#projectstable').DataTable({
"ajax":{
url: "api/projects",
"dataSrc": ''
},
"columns": [
{ "data": "title" },
{ "data": "status" },
{ "data": "features" , render: "passed"},
{ "data": "features" , render: "failed"},
]
});
样本数据
[{
"id": "demo",
"title": "demo project",
"features": {
"passed": 1,
"failed": 0,
"skipped": 0,
"wip": 0
}
}]
它在控制台中给出Uncaught TypeError: column is undefined。现在,如果我用column 替换columns,那么它会在警报中给出以下错误
DataTables warning: table id=projectstable - Requested unknown parameter '0' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4
【问题讨论】:
-
您定义了 4 列,但 HTML 只有 3 列
-
表头有 2 行。第 3 列有 2 列在第 2 行
标签: javascript jquery datatables