priority sort help

priority sort help

bmaggotbmaggot Posts: 8Questions: 0Answers: 0
edited August 2011 in General
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?

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    [code]
    function fnPriority( a ) {
    [/code]

    missing keyword "function"
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    This example should help: http://datatables.net/release-datatables/examples/plug-ins/sorting_sType.html

    Allan
This discussion has been closed.