最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - DataTables change default sort order - Stack Overflow

programmeradmin2浏览0评论

I use datatables with option 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.

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

Is there a way to configure this and change default order setting?

I use datatables with option 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.

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

Is there a way to configure this and change default order setting?

Share Improve this question edited Jul 11, 2019 at 11:22 Yevhen Horbunkov 15.6k3 gold badges27 silver badges45 bronze badges asked Jul 11, 2019 at 10:20 SpringSpring 11.9k30 gold badges121 silver badges192 bronze badges 3
  • 1 Have you checked out this page? – Yevhen Horbunkov Commented Jul 11, 2019 at 11:14
  • @U25lYWt5IEJhc3RhcmQg works! I can accept if you answer the question – Spring Commented Jul 11, 2019 at 11:28
  • 1 thanks, it is a kind of advice that isn't worth an answer – Yevhen Horbunkov Commented Jul 11, 2019 at 11:43
Add a ment  | 

2 Answers 2

Reset to default 3

In you DataTable Configuration inside javascript you can specify that with help of,

 "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/reference/option

发布评论

评论列表(0)

  1. 暂无评论