priority sort help
priority sort help
Hello,
I was trying to do pseudo enumerated sort as shown in http://datatables.net/plug-ins/sorting#Priority
[code]fnPriority( a ) {
if ( a == "Laukiama peržiūros" ) { return 1; }
else if ( a == "Užsakyta" ) { return 2; }
else if ( a == "Atmesta" ) { return 3; }
else if ( a == "Nupirkta" ) { return 4; }
return 5;
}
jQuery.fn.dataTableExt.oSort['priority-asc'] = function(a,b) {
var x = fnPriority( a );
var y = fnPriority( b );
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['priority-desc'] = function(a,b) {
var x = fnPriority( a );
var y = fnPriority( b );
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};[/code]
I tried to put in different .js file and in main code but there's an error:
[quote]missing ; before statement
[Break On This Error] fnPriority( a ) { [/quote]
Where exactly should I put this code?
I was trying to do pseudo enumerated sort as shown in http://datatables.net/plug-ins/sorting#Priority
[code]fnPriority( a ) {
if ( a == "Laukiama peržiūros" ) { return 1; }
else if ( a == "Užsakyta" ) { return 2; }
else if ( a == "Atmesta" ) { return 3; }
else if ( a == "Nupirkta" ) { return 4; }
return 5;
}
jQuery.fn.dataTableExt.oSort['priority-asc'] = function(a,b) {
var x = fnPriority( a );
var y = fnPriority( b );
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['priority-desc'] = function(a,b) {
var x = fnPriority( a );
var y = fnPriority( b );
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};[/code]
I tried to put in different .js file and in main code but there's an error:
[quote]missing ; before statement
[Break On This Error] fnPriority( a ) { [/quote]
Where exactly should I put this code?
This discussion has been closed.
Replies
function fnPriority( a ) {
[/code]
missing keyword "function"
Allan