Please guide as to what I'm doing wrong!
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 Table Debugger result:
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>
each orderDataType needs to be in its own object. https://datatables.net/reference/option/columns.orderDataType
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.