Multi column sorting not working
Multi column sorting not working
harikrishnan
Posts: 10Questions: 0Answers: 0
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.
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.
This discussion has been closed.
Replies
Allan
http://datatables.net/release-datatables/examples/basic_init/multi_col_sort.html