DataTables warning: Requested unknown parameter '0' from the data source for row '0'
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了DataTables warning: Requested unknown parameter '0' from the data source for row '0'相关的知识,希望对你有一定的参考价值。
问题:DataTables warning: Requested unknown parameter ‘0‘ from the data source for row ‘0‘
代码:
<script type="text/javascript"> var data = [ {"Name":"UpdateBootProfile","Result":"PASS","ExecutionTime":"00:00:00","Measurement":[]}, {"Name":"NRB Boot","Result":"PASS","ExecutionTime":"00:00:50.5000000","Measurement":[{"TestName":"TOTAL_TURN_ON_TIME","Result":"PASS","Value":"50.5","LowerLimit":"NaN","UpperLimit":"NaN","ComparisonType":"nctLOG","Units":"SECONDS"}]}, {"Name":"NvMgrCommit","Result":"PASS","ExecutionTime":"00:00:00","Measurement":[]}, {"Name":"SyncNvToEFS","Result":"PASS","ExecutionTime":"00:00:01.2500000","Measurement":[]} ]; $(function() { var testsTable = $(‘#tests‘).dataTable({ bJQueryUI: true, aaData: data, aoColumns: [ { mData: ‘Name‘ }, { mData: ‘Result‘ }, { mData: ‘ExecutionTime‘ },
{ mData: ‘localtion‘ }
] }); }); </script>
报错原因: 这个location字段,有数据的时候出现,没有数据的时候,就成这个样子了
aoColumns: [
{ mData: ‘Name‘ },
{ mData: ‘Result‘ },
{ mData: ‘ExecutionTime‘ }
导致页面错误。
改正的方法是:
1.$(
‘#example‘
).dataTable( {
"columns"
: [
null
,
null
,
null
,
{
"data"
:
"office"
,
// can be null or undefined
"defaultContent"
:
""
}
]
} ); 加上【"defaultContent"
:
""
】
2. 用都是数组的形式
var data = [
["UpdateBootProfile","PASS","00:00:00",[]] ,
["NRB Boot","PASS","00:00:50.5000000",[{"TestName":"TOTAL_TURN_ON_TIME","Result":"PASS","Value":"50.5","LowerLimit":"NaN","UpperLimit":"NaN","ComparisonType":"nctLOG","Units":"SECONDS"}]] ,
["NvMgrCommit","PASS","00:00:00",[]] ,
["SyncNvToEFS","PASS","00:00:01.2500000",[]]
];
解决链接:
https://datatables.net/manual/tech-notes/4
https://datatables.net/reference/option/columns.defaultContent
http://stackoverflow.com/questions/16539578/datatables-warning-requested-unknown-parameter-0-from-the-data-source-for-row
以上是关于DataTables warning: Requested unknown parameter '0' from the data source for row '0'的主要内容,如果未能解决你的问题,请参考以下文章
DataTables warning: Requested unknown parameter '0' from the data source for row '0'
C#实现库存管理系统显示物料信息时报500错(DataTables warning: table id=myTable1 - Ajax error.)
xxl-job 的一个小bug: DataTables warning: table id=job_list - Ajax error. For more information about this