Skip to content

Instantly share code, notes, and snippets.

@csessig86
Created November 5, 2013 22:59
Show Gist options
  • Save csessig86/7327902 to your computer and use it in GitHub Desktop.
Save csessig86/7327902 to your computer and use it in GitHub Desktop.
Format percent column with DataTables
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"percent-pre": function ( a ) {
var x = (a == "-") ? 0 : a.replace( /%/, "" );
return parseFloat( x );
},
"percent-asc": function ( a, b ) {
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
},
"percent-desc": function ( a, b ) {
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment