DataTables 警告:从行“0”的数据源请求未知参数“0”

2024-04-15

有人知道下面这个非常简单的 HTML 文件有什么问题吗?

我只是想用对象数组 http://datatables.net/release-datatables/examples/ajax/objects.html作为 DataTables 的数据源:

测试.html:

<html>
    <head>
        <link type="text/css" rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/redmond/jquery-ui.css">
        <link type="text/css" rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.2/css/jquery.dataTables_themeroller.css">
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
        <script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.2/jquery.dataTables.min.js"></script>
        <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' }
                    ]
                });
            });

        </script>
    </head>
    <body>
        <table id="tests">
        <thead>
            <tr>
                <th>Name</th>
                <th>Result</th>
                <th>ExecutionTime</th>
            </tr>
        </thead>
            <tbody>
            </tbody>
        </table>
    </body>
</html>

UPDATE:好的,我已经得到作者的答案了使用较新版本的 DataTables 或将 mData 重命名为 mDataProp http://datatables.net/forums/discussion/15519/requested-unknown-parameter-0390039-from-the-data-source-for-row-0390039


For null or 未定义值错误,只需将此行添加到属性:,columnDefs: [ { "defaultContent": "-", "targets": "_all" } ]

例子 :

oTable = $("#bigtable").dataTable({
  columnDefs: [{
    "defaultContent": "-",
    "targets": "_all"
  }]
});

警报框将不会再次显示,任何空值都将替换为您指定的值。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

DataTables 警告:从行“0”的数据源请求未知参数“0” 的相关文章

随机推荐