我有一个 jquery 数据表,其中日期列格式为 2018 年 2 月 16 日,但是当它排序时,它没有正确排序。
我已经使用了提到的所有与日期相关的列类型Here
但似乎没有任何作用。我该如何解决?
这是代码
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="panel-body btnsize">
<table class="table table-striped table-bordered dttable" id="JsDataTable" style="border-radius: 17px 17px 0 0; border-style: solid; border-color: #fcfdfa;" width:100%;>
<thead>
<tr>
<th style="width: 1px !important;" class="tblth">
Sr
</th>
<th class="tblth" style="width:13% !important;">
Date <i class="fa fa-fw fa-sort"></i>
</th>
</tr>
</thead>
<tbody class="dtbody tblth" style="color: #004D6B;">
</tbody>
</table>
</div>
var table = $("#JsDataTable").DataTable({
scrollY: '50vh',
scrollCollapse: true,
"aaData": response,
"pagingType": "full_numbers",
"dom": '<"top"i>rt<"bottom"flp><"clear">',
"sDom": 'Rfrtlip',
"bInfo": true,
"lengthMenu": [
[10, 20, 30, -1],
[10, 20, 30, "All"]
],
"columnDefs": [{
"searchable": false,
"orderable": false,
"targets": [0, 1, 2, 3, 4],
"type": 'natural'
}],
"order": [
[1, 'asc']
],
"aoColumns": [{
"mData": null
},
{
"mData": "Date",
'bSortable': true,
"sType": "natural"
},
],
"searching": true,
"paging": true,
"bAutoWidth": false,
"fixedColumns": false,
//order: [],
});