gpt4 book ai didi

javascript - 无法读取简单表的未定义属性 'mData'

转载 作者:行者123 更新时间:2023-12-03 11:02:16 24 4
gpt4 key购买 nike

请指导我做错了什么!

Javascript:

<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js"></script>
<script>
$(function() {

$('#example').dataTable({
"scrollY" : 800,
"scrollX" : true,
"paging" : false,
"ordering" : true,
//"order": [[ 3, "desc" ]],
"info" : true,
"columns": [{
"orderDataType": "dom-text-numeric",
"orderDataType": "dom-text-numeric",
"orderDataType": "dom-text-numeric",
"orderDataType": "dom-text-numeric",
"orderDataType": "dom-text-numeric",
"orderDataType": "dom-text-numeric"
}]
});
});
</script>

HTML:

<table id="example" style="border-collapse:collapse;" border="1">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>

<tbody>


<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
<tr>
<td>Garrett Winters</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>63</td>
<td>2011/07/25</td>
<td>$170,750</td>
</tr>
</tbody>
</table>

Datatables 表调试器结果:

http://debug.datatables.net/ogimac

JSFiddle:

http://jsfiddle.net/sajjansarkar/pqzkx1oj/1/

最佳答案

<script>
$(function() {

$('#example').dataTable({
"scrollY" : 800,
"scrollX" : true,
"paging" : false,
"ordering" : true,
//"order": [[ 3, "desc" ]],
"info" : true,
"columns": [
{"orderDataType": "dom-text-numeric"},
{"orderDataType": "dom-text-numeric"},
{"orderDataType": "dom-text-numeric"},
{"orderDataType": "dom-text-numeric"},
{"orderDataType": "dom-text-numeric"},
{"orderDataType": "dom-text-numeric"}
]
});
});
</script>

每个 orderDataType 都需要位于其自己的对象中。 https://datatables.net/reference/option/columns.orderDataType

关于javascript - 无法读取简单表的未定义属性 'mData',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28030236/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com