Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82207

Can you disable sorting on the datatable but also have a default ordering for the first column?

$
0
0

Im trying to order my datatable by first name (first column) and i am only able to do if sorting isnt disabled for the table.

This scenario 100% requires that the table must not be sortable by the user, but does this also mean that i cant apply a default order on the first column?

I have tried this but obviously this alone allows sorting by the user

{
   order: [[0, "asc"]]
}

So i then tried this but this doesnt order the first column

{
   order: [[0, "asc"]],
   bSort: false,
}

So i then tried this but again it did not work

{
 bSort: false,
 columnDefs: [
      {
          targets: [0, 1],   //first name & last name
          orderable: true
      },
      {
          targets: [ 0 ],
          orderData: [ 0, 1 ]
       },
       {
          targets: [ 1 ],
          orderData: [ 1, 0 ]
        }
  ]
}

I know i can specify ordering for each column but this table is a dynamic table and there is a varying number of columns depending on the user. It could have 3 columns or it could have 15 so this is not applicable to my scenario.

Any help is massively appreciated. Thanks!


Viewing all articles
Browse latest Browse all 82207

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>