Question

I'm using admin theme whichone created by some guy and it orders all dada by second column in my dataTables. I tried to change datatable jquery file, but nothin happened. He uses different initialization to call it..

jQuery(document).ready(function() {    
     App.init(); // initlayout and core plugins
     TableAdvanced.init();              
  });

And I don't know what to change to disable ordering or make it order by first column.. This is the theme: http://keenthemes.com/preview/metronic_admin/table_advanced.html Maybe someone know a answer?

Était-ce utile?

La solution

If you want to add the Sorting by the first column you will need to use something like this

$("#sample_1").dataTable({
   "aaSorting" : [[0,"desc"]],
   "bDestroy":true
});

Note: Using "bDestroy" it will replace your datatable with one with the new properties, so doing this will overwrite the previous configuration of the dataTable.

I think that the best solution is to look out where the datatable is created inside that TableAdvanced.init()

And add the parameter aaSorting to it

"aaSorting" : [[0,"desc"]]

This could work http://datatables.net/examples/basic_init/table_sorting.html

Autres conseils

In metronic admin theme there is a file "../assets/global/scripts/datatable.js" in the file find "columnDefs" you will see the below code

"columnDefs": [{ // define columns sorting options(by default all columns are sortable extept the first checkbox column)
                    'orderable': false,
                    'targets': [0]
                }],

This code is stopping first column to be sortable. And the above mentioned answer by @Eduardo Quintana is a way to making a column sortable.

I m currently used this one. Any kind of setting this js file just adds another column like [ID] returns from your query which have no effect for sorting desc order and search option how ever other columns works fine

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top