Sha256: 3b028a55e89014972513ce9d7541b04e1d4d447f037ba0896a8793472558d20d

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

/**
 * This plug-in will provide numeric sorting for numeric columns which have
 * extra formatting, such as thousands separators, currency symbols or any other
 * non-numeric data.
 * 
 * By default when a cell is found to have no numeric data its value is sorted
 * numerically as if its value were 0. This could also be altered to be Inifnity
 * or -Infinity as required.
 *
 * DataTables 1.10+ has formatted number detection and sorting abilities built-
 * in. As such this plug-in is marked as deprecated, but might be useful when
 * working with old versions of DataTables.
 *
 *  @name Formatted numbers
 *  @summary Sort numbers which are displayed with thousand separators
 *  @deprecated
 *  @author [Allan Jardine](http://sprymedia.co.uk)
 *
 *  @example
 *    $('#example').dataTable( {
 *       columnDefs: [
 *         { type: 'formatted-num', targets: 0 }
 *       ]
 *    } );
 */

jQuery.extend( jQuery.fn.dataTableExt.oSort, {
	"formatted-num-pre": function ( a ) {
		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;
	}
} );

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jquery-datatables-1.10.20 app/assets/javascripts/datatables/plugins/sorting/formatted-numbers.js
jquery-datatables-1.10.19.1 app/assets/javascripts/datatables/plugins/sorting/formatted-numbers.js
jquery-datatables-1.10.19 app/assets/javascripts/datatables/plugins/sorting/formatted-numbers.js
jquery-datatables-1.10.18 app/assets/javascripts/datatables/plugins/sorting/formatted-numbers.js