aaSorting not working
aaSorting not working
I have a datatable being loading in chucks due to a slugish database and having to use IE8. I can sort using fnSort, which works fine with my custom sort plugin. However, when I use aaSorting nothing happens. The plugin is never used and no sorting occurs.
Any ideas?
[code]
oTable = jQuery('#siteDetail').dataTable( {
"bProcessing": false,
"bServerSide": false,
"sAjaxSource": 'View/Data/DetailDataSite.cfc?method=getdetaildata_json',
"bAutoWidth": false,
"bFilter": false,
"bInfo": true,
"bJQueryUI": false,
"bPaginate": true,
"bFilter": true,
"sPaginationType": "four_button",
"bSort": false,
"iDisplayLength": 25,
"aLengthMenu": [[25, 50, 75, 100], [25, 50, 75, 100]],
"bDeferRender": true,
"sDom": '<"top"lfip<"clear">>rt<"bottom"<"#spacer">ip<"clear">>',
"oLanguage": {
"sLoadingRecords": "Please wait - loading...",
"sEmptyTable": "Please wait - loading...",
"sZeroRecords": "Please wait - loading..."
},
"aoColumns": objCols.aaData,
"aaSorting": [ [10, 'asc']],
fnServerData: function ( sSource, aoData, fnDraw ) {
for (i=1; i<=10; i++){
prevPage = i-1;
if(i > 1){
params = params.replace('PAGENUM=' + prevPage, 'PAGENUM=' + i);
}
jQuery.ajax({
error: function(XMLHttpRequest, textStatus, errorThrown){alert(errorThrown)},
"dataType": "json",
"type": "POST",
"url": sSource,
"data": params,
"success": function(resp){
if(resp.iTotalRecords > 0){
fnDraw(resp);
}
}
});
}
}
} );
// jQuery('#siteDetail').bind('change', function () { sortTable(); });
// setTimeout("sortTable(colSort, sortAD)", 8000);
// setTimeout(function(){sortTable(colSort, sortAD)}, 12000);
}
function sortTable(colSort, sortAD){
oTable.fnSort( [ [ colSort , sortAD ] ] );
}
var sort = 0;
jQuery.fn.dataTableExt.oSort['numeric-comma-asc'] = function(a,b) {
a = a.replace( /<.*?>/g, "" );
b = b.replace( /<.*?>/g, "" );
a = a.replace(/$/, "");
b = b.replace(/$/, "");
if (a.indexOf( '(' ) > -1 ){
a = a.replace(/\(/, "");
a = a.replace(/\)/, "");
a = a.replace(/,/g, "");
a = a * -1;
}
if (sort == 0){
alert('a: ' + a);
sort = 1;
}
if (b.indexOf( '(' ) > -1 ){
b = b.replace(/\(/, "");
b = b.replace(/\)/, "");
b = b.replace(/,/g, "");
b = b * -1;
}
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
};
var sort = 0;
jQuery.fn.dataTableExt.oSort['numeric-comma-desc'] = function(a,b) {
a = a.replace( /<.*?>/g, "" );
b = b.replace( /<.*?>/g, "" );
a = a.replace(/$/, "");
b = b.replace(/$/, "");
if (a.indexOf( '(' ) > -1 ){
a = a.replace(/\(/, "");
a = a.replace(/\)/, "");
a = a.replace(/,/g, "");
a = a * -1;
}
if (b.indexOf( '(' ) > -1 ){
b = b.replace(/\(/, "");
b = b.replace(/\)/, "");
b = b.replace(/,/g, "");
b = b * -1;
}
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
};
[/code]
Any ideas?
[code]
oTable = jQuery('#siteDetail').dataTable( {
"bProcessing": false,
"bServerSide": false,
"sAjaxSource": 'View/Data/DetailDataSite.cfc?method=getdetaildata_json',
"bAutoWidth": false,
"bFilter": false,
"bInfo": true,
"bJQueryUI": false,
"bPaginate": true,
"bFilter": true,
"sPaginationType": "four_button",
"bSort": false,
"iDisplayLength": 25,
"aLengthMenu": [[25, 50, 75, 100], [25, 50, 75, 100]],
"bDeferRender": true,
"sDom": '<"top"lfip<"clear">>rt<"bottom"<"#spacer">ip<"clear">>',
"oLanguage": {
"sLoadingRecords": "Please wait - loading...",
"sEmptyTable": "Please wait - loading...",
"sZeroRecords": "Please wait - loading..."
},
"aoColumns": objCols.aaData,
"aaSorting": [ [10, 'asc']],
fnServerData: function ( sSource, aoData, fnDraw ) {
for (i=1; i<=10; i++){
prevPage = i-1;
if(i > 1){
params = params.replace('PAGENUM=' + prevPage, 'PAGENUM=' + i);
}
jQuery.ajax({
error: function(XMLHttpRequest, textStatus, errorThrown){alert(errorThrown)},
"dataType": "json",
"type": "POST",
"url": sSource,
"data": params,
"success": function(resp){
if(resp.iTotalRecords > 0){
fnDraw(resp);
}
}
});
}
}
} );
// jQuery('#siteDetail').bind('change', function () { sortTable(); });
// setTimeout("sortTable(colSort, sortAD)", 8000);
// setTimeout(function(){sortTable(colSort, sortAD)}, 12000);
}
function sortTable(colSort, sortAD){
oTable.fnSort( [ [ colSort , sortAD ] ] );
}
var sort = 0;
jQuery.fn.dataTableExt.oSort['numeric-comma-asc'] = function(a,b) {
a = a.replace( /<.*?>/g, "" );
b = b.replace( /<.*?>/g, "" );
a = a.replace(/$/, "");
b = b.replace(/$/, "");
if (a.indexOf( '(' ) > -1 ){
a = a.replace(/\(/, "");
a = a.replace(/\)/, "");
a = a.replace(/,/g, "");
a = a * -1;
}
if (sort == 0){
alert('a: ' + a);
sort = 1;
}
if (b.indexOf( '(' ) > -1 ){
b = b.replace(/\(/, "");
b = b.replace(/\)/, "");
b = b.replace(/,/g, "");
b = b * -1;
}
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
};
var sort = 0;
jQuery.fn.dataTableExt.oSort['numeric-comma-desc'] = function(a,b) {
a = a.replace( /<.*?>/g, "" );
b = b.replace( /<.*?>/g, "" );
a = a.replace(/$/, "");
b = b.replace(/$/, "");
if (a.indexOf( '(' ) > -1 ){
a = a.replace(/\(/, "");
a = a.replace(/\)/, "");
a = a.replace(/,/g, "");
a = a * -1;
}
if (b.indexOf( '(' ) > -1 ){
b = b.replace(/\(/, "");
b = b.replace(/\)/, "");
b = b.replace(/,/g, "");
b = b * -1;
}
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
};
[/code]
This discussion has been closed.
Replies