Currency Sorting Example
Currency Sorting Example
Are there any examples of the currency sorting and the currency type detection functions posted anywhere?
I have seen the code snippets on the plug-ins pages, but I am looking for a full blown examples like those in the examples section. For some reason I haven't been able to get the currency sorting working and I wanted a live sample to compare it to in an attempt to discover what I am doing wrong.
Love DataTables by the way, everything else is working really well.
I have seen the code snippets on the plug-ins pages, but I am looking for a full blown examples like those in the examples section. For some reason I haven't been able to get the currency sorting working and I wanted a live sample to compare it to in an attempt to discover what I am doing wrong.
Love DataTables by the way, everything else is working really well.
This discussion has been closed.
Replies
If that doesn't work, perhaps you can post your initialisation code here.
Allan
Here is my initialisation code.
[code]
jQuery.fn.dataTableExt.aTypes.push(
function ( sData )
{
var sValidChars = "0123456789.-,";
var Char;
/* Check the numeric part */
for ( i=1 ; i
Allan
Table code looks like this:
[code]
First Name
Last Name
Current Vehicle
Book Value
Equity
Payoff
Nancy
Bell
2006 Honda Civic Si
$11,323.34
$7,856.23
$3,265.45
Robert
Berray
2007 Honda Pilot
$15,232.33
$13,523.96
$2,523.21
[/code]
This is just a sample table so the links don't go anywhere right now.
What you need to do is to combine the currency plug-in you've got there, with the "number with HTML" plug-in: http://datatables.net/plug-ins/sorting#numbers_html . The auto type detection will need a similar, but small, modification.
Regards,
Allan
I've got a table similar to tjrowe's with href links, but with euro currency instead of dollar signs and I just can't get it to sort right. Is there a full blown example which combines the two plugins 'currency sorting' and 'number with html', preferably with euro signs as well?
Allan
Thanks. What I don't get is how to combine the two plugins. Do I need to run Numbers with HTML first and Euro currency afterwards or do they need to be combined in one
Allan
[code]
var x = a == "-" ? 0 : a.replace( /,/g, "" ).replace(/\$/g,"");
var y = b == "-" ? 0 : b.replace( /,/g, "" ).replace(/\$/g,"");
//x = x.substring( 1 );
//y = y.substring( 1 );
[/code]