Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
161
rated 0 times [  163] [ 2]  / answers: 1 / hits: 29495  / 12 Years ago, sun, october 14, 2012, 12:00:00

I am working on datatable plugin in Jquery. And have to set the default column by which the data is sorted so I mean that :



I have a table with 4 columns and by default the data is sorted by column no 1, I want that the data should be sorted by column number 2 or 3.



How that can be done:



$('#tblMainTable').dataTable({
bJQueryUI : true,
sDom : 'R<Hlfr>t<Fip<',
aoColumns : [
{bSortable : false},
null,
null,
null,
{bSortable : false},
{bSortable : false}
],
aaSorting: [[ 2, desc ]]
});


I specified that in aaSorting but not getting the result.



Please shed some light?


More From » jquery

 Answers
11

The example in the datatable api does it like this:



$(document).ready(function() {
var oTable = $('#example').dataTable();

// Sort immediately with columns 0 and 1
oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
} );

[#82565] Friday, October 12, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
zachary

Total Points: 175
Total Questions: 89
Total Answers: 108

Location: Fiji
Member since Wed, Jul 14, 2021
3 Years ago
zachary questions
;