Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82109

Please help me with sorting.

$
0
0


the following code is not sorting when it has comma in it, other wise it is working fine. it you take out the comma from the following code it is working as expected.


the data is when sorted as desc

-2,598.00
-3,493.70
-350.00
-36.00
-435.75
-8,200.00
0.00
0.00
17,444.00
27,200.00
736.75

 


jQuery.extend( jQuery.fn.dataTableExt.oSort, {

    "formatted-num-pre": function ( a ) {

        a = (a==="-") ? 0 : a.replace( /[^\d\-\.]/g, "" );
        return parseFloat( a );

    },
 
    "formatted-num-asc": function ( a, b ) {
        return a - b;
    },

 
    "formatted-num-desc": function ( a, b ) {
        return b - a;
    }

} );
			
			
	
/* Table initialisation */
$(document).ready( function() {
  $('#myTable').dataTable( {
    "sPaginationType": "full_numbers",
    "aoColumns": [null,null,null,null,null,{ "sType": "formatted-num" }, null,null]
  } );
} )

 

Viewing all articles
Browse latest Browse all 82109

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>