• 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
  • 相关阅读:
    Windows解决端口占用
    Oracle数字格式化
    Windows生成项目目录结构
    IDEA激活教程
    Windows搭建SMB服务
    在右键新建菜单中添加新项目
    Fastjson1.2.47反序列化+环境搭建+漏洞复现
    nmap常用命令及端口
    Shiro反序列化复现
    CVE-2020-0796漏洞复现
  • 原文地址:https://www.cnblogs.com/boyuan01/p/5564601.html
Copyright © 2020-2023  润新知