无法为简单的 table 读取未定义的 属性 'mData'
Cannot read property 'mData' of undefined for a simple table
请指导我做错了什么!
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>0,800</td>
</tr>
<tr>
<td>Garrett Winters</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>63</td>
<td>2011/07/25</td>
<td>0,750</td>
</tr>
</tbody>
</table>
数据表Table调试器结果:
http://debug.datatables.net/ogimac
JSFiddle:
<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:
<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>0,800</td>
</tr>
<tr>
<td>Garrett Winters</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>63</td>
<td>2011/07/25</td>
<td>0,750</td>
</tr>
</tbody>
</table>
数据表Table调试器结果:
http://debug.datatables.net/ogimac
JSFiddle:
<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