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'
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
問題: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
轉載于:https://www.cnblogs.com/boyuan01/p/5564601.html
總結
以上是生活随笔為你收集整理的DataTables warning: Requested unknown parameter '0' from the data source for row '0'的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: .Net接口调试与案例
- 下一篇: 第一次办信用卡办哪个等级的卡比较好?都有