0

Please help me to disable the sortorder of Metronic Admin Theme. Or just maybe disable sortorder until user click on the sortorder icon.

I follow this, but somehow, it's not working with me too.

I already change the code from columnDefs (from assets/pages/scripts/table-datatables-managed.min.js) into:

columnDefs: [{
   orderable: false,
   targets: [0]
}, 

But it's not working. The icon sort always activate when I refresh page. But when I change language from this file, it's working. I already do the same in /assets/global/scripts/datatable.js but it's not work too.

Please help.

Nguyen Hoang
  • 540
  • 5
  • 25
  • Basically set `order: []` in your DataTables attributes. Disabling ordering for a column does not reset the overall default ordering, it just prevent users form ordering that particular column. – davidkonrad Dec 21 '17 at 08:05
  • Thank you. It work. My browser cached and I need to clear cache. After chat, it worked. Thank you @davidkonrad – Nguyen Hoang Dec 21 '17 at 10:27

1 Answers1

1

So a working example: But when I change language from this file, it's working.

Provide a link to your not working code

Edit: To disable sorting completely, use this in your init setting

"ordering": false,

While to disable for specific column(s), use this in your init setting

"columns": [
        { "orderable": true },
        { "orderable": true },
        { "orderable": false },
        { "orderable": false },
        { "orderable": false },
        { "orderable": true }
    ]

This example might help you understand sorting better

https://jsfiddle.net/g1y8eu8v/1/

Here are some reference links:

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

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

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

jking
  • 194
  • 2
  • 9
  • I mean in the file there are a part for modife language. And other part is for sortorder. When I translate the language from English to Vietnamesse. The language in datable is change. But when I change the code for sortorder to "false". it's not working. – Nguyen Hoang Dec 21 '17 at 07:09
  • You translated the language, and the sort is disabled. Why do you need to the code to `false`. – jking Dec 21 '17 at 07:11