custom sorting issue
custom sorting issue
Hi Allan:
I am trying to utilize the priority sort code with slight modifications made, however, I get the following error:
oSort[iDataType +
[Break On This Error] aoData[b]._aData[iDataSort] line 4000
[code]
priority= function (a) {
a = a.toLowerCase();
if (a == "january") { return 1; }
else if (a == "february") { return 2; }
else if (a == "march") { return 3; }
else if (a == "april") { return 4; }
else if (a == "may") { return 5; }
else if (a == "june") { return 6; }
else if (a == "july") { return 7; }
else if (a == "august") { return 8; }
else if (a == "september") { return 9; }
else if (a == "october") { return 10; }
else if (a == "november") { return 11; }
else if (a == "december") { return 12; }
return 13;
console.log("priority function ran");
}
jQuery.fn.dataTableExt.oSort['month-asc'] = function (a, b) {
var x = priority(a);
var y = priority(b);
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['month-desc'] = function (a, b) {
var x = priority(a);
var y = priority(b);
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};
[/code]
I am looking to see if you can shed some light on this.
Thanks again,
I am trying to utilize the priority sort code with slight modifications made, however, I get the following error:
oSort[iDataType +
[Break On This Error] aoData[b]._aData[iDataSort] line 4000
[code]
priority= function (a) {
a = a.toLowerCase();
if (a == "january") { return 1; }
else if (a == "february") { return 2; }
else if (a == "march") { return 3; }
else if (a == "april") { return 4; }
else if (a == "may") { return 5; }
else if (a == "june") { return 6; }
else if (a == "july") { return 7; }
else if (a == "august") { return 8; }
else if (a == "september") { return 9; }
else if (a == "october") { return 10; }
else if (a == "november") { return 11; }
else if (a == "december") { return 12; }
return 13;
console.log("priority function ran");
}
jQuery.fn.dataTableExt.oSort['month-asc'] = function (a, b) {
var x = priority(a);
var y = priority(b);
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['month-desc'] = function (a, b) {
var x = priority(a);
var y = priority(b);
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};
[/code]
I am looking to see if you can shed some light on this.
Thanks again,
This discussion has been closed.
Replies
Allan
Here is my initialization code:
[code]
/* generate a table - dataTable */
$('#flood_reports').html('');
var oTable = $('#daily_flood_reports_table').dataTable({
"iDisplayLength": 9999,
//"iCookieDuration": 0,
"oLanguage": {
"sSearch": "Search Flood Reports by date:",
"sLengthMenu": 'Show ' +
'most recent' +
'10' +
'25' +
'50' +
'100' +
'All' +
' entries'
},
"sPaginationType": "full_numbers",
"aaSorting": [[0, "desc", 0], [1, "desc", 0], [2, "desc", 0]],
"aaData": csv_flood_reports,
"aoColumns": [
{ "sTitle": "Year", "sType": "month-desc" }, // "sType": "date"
{"sTitle": "Month" },
{ "sTitle": "Day" },
{ "sTitle": "English" },
{ "sTitle": "Français" }
]
});
[/code]
Thanks in advance.
Allan