简体   繁体   English

DataTables更改默认排序顺序

[英]DataTables change default sort order

I use with option serverSide: true . 我用与选项serverSide: true I see it in the ajax request body that it sends the default ordering option, which is the first column and ASC always. 我在ajax请求正文中看到它发送默认的排序选项,即第一列和始终为ASC。

order[0][column]=0&order[0][dir]=asc

Is there a way to configure this and change default order setting? 有没有一种方法可以配置此设置并更改默认订单设置?

In you DataTable Configuration inside javascript you can specify that with help of, 在javascript中的“数据表配置”中,您可以借助以下命令进行指定,

 "order": [[1, "asc"]],

I hope this will help you! 我希望这能帮到您! Thanks! 谢谢!

Solution is below in table settings: 解决方案如下表设置所示:

    { ....
    serverSide: true,
    order: [ 4, 'desc' ]
    ajax: { ...

More details on available options: 有关可用选项的更多详细信息:

https://datatables.net/reference/option https://datatables.net/reference/option

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM