Possible issue with currency sorting plugin

Possible issue with currency sorting plugin

baldwindavidbaldwindavid Posts: 14Questions: 0Answers: 0
edited October 2010 in Plug-ins
Hi Allan:
I was implementing the "currency" sorting plugin (http://datatables.net/plug-ins/sorting) and running into an issue with columns containing a dash. I am using a dash to represent columns without data.

The plugin seems to support the dash via the first few lines...
[code]
var x = a == "-" ? 0 : a.replace( /,/g, "" );
var y = b == "-" ? 0 : b.replace( /,/g, "" );
[/code]

However, setting the dashes to zero then causes an issue in the next process which is intended to remove the leading dollar sign...
[code]
x = x.substring( 1 );
y = y.substring( 1 );
[/code]

Calling substring on zero is throwing an error. I think I got it working correctly by simply setting the initial bit to "$0"...
[code]
var x = a == "-" ? "$0" : a.replace( /,/g, "" );
var y = b == "-" ? "$0" : b.replace( /,/g, "" );
[/code]

Does that seem correct?

Best Regards,
David Baldwin
This discussion has been closed.