From 8214042cfdd6facad36aae287cbee60d6b96a4ee Mon Sep 17 00:00:00 2001 From: Johan Lundberg Date: Wed, 2 Apr 2014 17:26:12 +0200 Subject: Added filters and type detection for dataTables. --- static/js/dataTables.percent.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 static/js/dataTables.percent.js (limited to 'static/js/dataTables.percent.js') diff --git a/static/js/dataTables.percent.js b/static/js/dataTables.percent.js new file mode 100644 index 0000000..c0b4db4 --- /dev/null +++ b/static/js/dataTables.percent.js @@ -0,0 +1,20 @@ +/** + * Created by lundberg on 4/2/14. + */ + +// http://datatables.net/plug-ins/sorting + +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)); + } +} ); -- cgit v1.1