Disable automatic sorting on the first column when using jQuery DataTables

前端 未结 7 2152
遥遥无期
遥遥无期 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条回答
  •  闹比i
    闹比i (楼主)
    2021-01-30 06:44

    var table;
    
    $(document).ready(function() {
    
        //datatables
        table = $('#userTable').DataTable({ 
    
            "processing": true, //Feature control the processing indicator.
            "serverSide": true, //Feature control DataTables' server-side processing mode.
            "order": [], //Initial no order.
             "aaSorting": [],
            // Load data for the table's content from an Ajax source
            "ajax": {
                "url": "",
                "type": "POST"
            },
    
            //Set column definition initialisation properties.
            "columnDefs": [
            { 
                "targets": [ ], //first column / numbering column
                "orderable": false, //set not orderable
            },
            ],
    
        });
    
    });
    

    set

    "targets": [0]
    

    to

     "targets": [ ]
    

提交回复
热议问题