Subversion-Projekte lars-tiefland.cienc

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
8 lars 1
/**
2
 * It is not uncommon for non-English speaking countries to use a comma for a
3
 * decimal place. This sorting plug-in shows how that can be taken account of in
4
 * sorting by adding the type `numeric-comma` to DataTables. A type detection
5
 * plug-in for this sorting method is provided below.
6
 *
7
 * Please note that the 'Formatted numbers' type detection and sorting plug-ins
8
 * offer greater flexibility that this plug-in and should be used in preference
9
 * to this method.
10
 *
11
 *  @name Commas for decimal place
12
 *  @summary Sort numbers correctly which use a common as the decimal place.
13
 *  @deprecated
14
 *  @author [Allan Jardine](http://sprymedia.co.uk)
15
 *
16
 *  @example
17
 *    $('#example').dataTable( {
18
 *       columnDefs: [
19
 *         { type: 'numeric-comma', targets: 0 }
20
 *       ]
21
 *    } );
22
 */
23
 
24
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
25
	"numeric-comma-pre": function ( a ) {
26
		var x = (a == "-") ? 0 : a.replace( /,/, "." );
27
		return parseFloat( x );
28
	},
29
 
30
	"numeric-comma-asc": function ( a, b ) {
31
		return ((a < b) ? -1 : ((a > b) ? 1 : 0));
32
	},
33
 
34
	"numeric-comma-desc": function ( a, b ) {
35
		return ((a < b) ? 1 : ((a > b) ? -1 : 0));
36
	}
37
} );