[Docs] Plugins : Sorting : "formatted-num" functions are backwards

[Docs] Plugins : Sorting : "formatted-num" functions are backwards

dharknessdharkness Posts: 8Questions: 0Answers: 0
edited January 2010 in Bug reports
For example, formatted-num-asc(x,y) returns a number < 0 if x > y. The reason is that the -desc function is defined first, contrary to all of the other examples, but it has the code for the -asc version. Swapping -asc and -desc should solve the problem.

BTW, is there a way to get the numeric sType to ignore the comma thousands separators without using a custom function?

Replies

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    Hi dharkness,

    heh - getting good at this :-). Thanks for reporting this stuff that you are finding. This one is now also fixed.

    The built in sorting and type detection functions don't, as you know, allow commas. As such the two ways around this are to (1) use a plug-in, or (2) replace/modify the built-in functions. So basically, no, I'm afraid that the plug-in is the best way to go... You could stick the sort and type detection plug-ins at the bottom of your DataTables.js file and then it will all just happen without any extra code in your main script.

    Regards,
    Allan
  • mindsharemindshare Posts: 6Questions: 0Answers: 0
    edited November 2010
    I'm getting a JS "syntax error" in Firebug when trying to use the formatted-num plugin. I've triple-checked the code but I cannot see anything wrong. The script seems to be failing on this line:
    [code]if(x.indexOf('/')>=0)x = eval(x);[/code]
    Has anyone else encountered this issue?
  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    Not that I'm aware of. Try echoing out what 'x' is at that point using console.log or something and see what the value is.

    Allan
  • mindsharemindshare Posts: 6Questions: 0Answers: 0
    Ok... it's actually failing on the next line on the y variable which is echoing out as "20.00/".

    Here's a link: http://www.gotspace.mindsharestudios.com/?search-class=DB_CustomSearch_Widget-db_customsearch_widget&widget_number=preset-2&cs-all-0=&cs-listing_status-1=&cs-listing_price-2=&cs-listing_price-3=&cs-listing_city-4=&cs-listing_zip-5=&cs-listing_broker1-6=&cs-listing_type-7=retail&cs-listing_sqft-8=&cs-listing_sqft-9=&cs-listing_acres-10=&cs-listing_acres-11=&cs-listing_city-12=&search=Search
  • mindsharemindshare Posts: 6Questions: 0Answers: 0
    I got it to work by adding in two extra replace calls:

    [code] y = y.replace('/','');
    x = x.replace('/','');[/code]

    But that seems to indicate that their is a problem with the regex in the plugin, right?
This discussion has been closed.