zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    【POJ1961】period
    主席树入门
    noip模拟【tea】
    noip模拟【service】
    noip模拟【noname】
    clearfix清除浮动
    九大内置对象
    2017/10/10 jar包错误
    mybatis案例源码详解
    自动类型转换
  • 原文地址:https://www.cnblogs.com/boyuan01/p/5564601.html
Copyright © 2011-2022 走看看