Multi column sorting not working

Multi column sorting not working

harikrishnanharikrishnan Posts: 10Questions: 0Answers: 0
edited August 2012 in Feature requests
Hi ,

I have tried multiple-column sorting functionality from this link,http://datatables.net/release-datatables/examples/basic_init/multi_col_sort.html, in my work.But sorting resets when I sort second column of my table.
Below is my code:



jQuery.fn.dataTableExt.oSort['string-case-asc'] = function(x,y) {
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};

jQuery.fn.dataTableExt.oSort['string-case-desc'] = function(x,y) {
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};

var oTable = $('#myTable').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"sDom": 'RC<"clear">lfrtip',
"sScrollY": "320px",
"bScrollCollapse": true,
"bScrollAutoCss": false,
"bAutoWidth": false,
"bLengthChange": false,
"oColVis": {
"aiExclude": [0, 1, 5],
"buttonText": "Show / Hide Columns",
"bRestore": true,
"sAlign": "right"
},
"sAjaxSource": 'My url',
'fnServerData': function (sSource, aoData, fnCallback) {
$.ajax({
'dataType': 'json',
'contentType': 'application/json;',
'type': 'POST',
'url': sSource,
'data': "{'}",
'success': fnCallback
});
},
"sAjaxDataProp": "sspData",
"aoColumns": [
{ "mDataProp": "Code", "sType": 'string-case' },
{ "mDataProp": "Stage" ,"sType": 'string-case' },
{ "mDataProp": "Organization" ,"sType": 'string-case' },
{ "mDataProp": "City","sType": 'string-case' },
{ "mDataProp": "Province" ,"sType": 'string-case' },
{ "mDataProp": "Country" ,"sType": 'string-case' },
{ "mDataProp": "Language","sType": 'string-case' }
],
"aoColumnDefs": [{ "bSortable": false, "aTargets": [3]}],
"fnDrawCallback": function (o) {
var nColVis = $('div.ColVis', o.nTableWrapper)[0];
nColVis.style.width = "150px";
nColVis.style.marginRight = "340px";
nColVis.style.marginTop = "0px";
nColVis.style.height = "20px";
},
"fnInitComplete": function () {
//My other codes
}
});

Please help me out of this problem.

Replies

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    I don't understand the issue I'm afraid? Do you mean you want multi column sorting applied automatically on a column? The aDataSort property can be used to do that.

    Allan
  • harikrishnanharikrishnan Posts: 10Questions: 0Answers: 0
    No Alan,I need to implement Multi-column sorting one just like

    http://datatables.net/release-datatables/examples/basic_init/multi_col_sort.html
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    Can you not just use aaSorting like in the example that you linked to?
This discussion has been closed.