Disable automatic sorting on the first column when using jQuery DataTables

前端 未结 7 2150
遥遥无期
遥遥无期 2021-01-30 06:16

I\'m using jQuery DataTables and I would like to know if there\'s possible to disable automatic sorting on the first column of the table?

My code looks like this:

<
相关标签:
7条回答
  • 2021-01-30 06:58

    In the newer version of datatables (version 1.10.7) it seems things have changed. The way to prevent DataTables from automatically sorting by the first column is to set the order option to an empty array.

    You just need to add the following parameter to the DataTables options:

    "order": [] 
    

    Set up your DataTable as follows in order to override the default setting:

    $('#example').dataTable( {
        "order": [],
        // Your other options here...
    } );
    

    That will override the default setting of "order": [[ 0, 'asc' ]].

    You can find more details regarding the order option here: https://datatables.net/reference/option/order

    0 讨论(0)
提交回复
热议问题