请指导我做错了什么!
使用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>
数据表表调试器结果:
http://debug.datatables.net/ogimac
的jsfiddle:
答案 0 :(得分: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