我有一个具有多列排序的dataTable,它可以工作,但我需要:
first column "asc" and second column desc -> how is this possible?
这是我的小提琴:https://jsfiddle.net/zukii/Lucq6vc5/28/
in this fiddle the column "Rating" is automatic default sorting "asc" and then the column "Price" should be automatic "desc"
var mytable = $('table.dt-tarif').dataTable({
"paging": false,
"info": false,
"searching": false,
"order": [[ 3, "desc" ]],
"aoColumnDefs": [
{
"bSortable": false,
"aTargets": [0]
},
{
"type": "currency", targets: 3
},
{
targets: [ 3 ],
orderData: [3, 4]
}
],
"language": {
"lengthMenu": "Zeige _MENU_",
"zeroRecords": "Keine Entwürfe vorhanden!",
"info": "Seite _PAGE_ von _PAGES_",
"infoEmpty": "Es konnte kein Entwurf gefunden werden.",
"infoFiltered": "",
"search": " ",
"paginate": {
"first": "Erste",
"last": "Letzte",
"next": "Vor",
"previous": "Zurück"
},
}
});
谢谢和问候;)
2 回答
您需要使用 2D array to achieve multi-column sorting 来存档结果 .
您还可以更改格式[columnIndex,“asc | desc”](例如[1,“desc”]进行排序 .
检查这是否有助于解决您的问题 .
这一个现在工作完美:)
https://jsfiddle.net/zukii/Lucq6vc5/37/