Subversion-Projekte lars-tiefland.webanos.zeldi.de

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
4 lars 1
/**
2
 * Sort numeric data which has a percent sign with it.
3
 *
4
 * DataTables 1.10+ has percentage data type detection and sorting abilities
5
 * built-in. As such this plug-in is marked as deprecated, but might be useful
6
 * when working with old versions of DataTables.
7
 *
8
 *  @name Percentage
9
 *  @summary Sort numeric data with a postfixed percentage symbol
10
 *  @deprecated
11
 *  @author [Jonathan Romley](http://jonathanromley.org/)
12
 *
13
 *  @example
14
 *    $('#example').dataTable( {
15
 *       columnDefs: [
16
 *         { type: 'percent', targets: 0 }
17
 *       ]
18
 *    } );
19
 */
20
 
21
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
22
	"percent-pre": function ( a ) {
23
		var x = (a == "-") ? 0 : a.replace( /%/, "" );
24
		return parseFloat( x );
25
	},
26
 
27
	"percent-asc": function ( a, b ) {
28
		return ((a < b) ? -1 : ((a > b) ? 1 : 0));
29
	},
30
 
31
	"percent-desc": function ( a, b ) {
32
		return ((a < b) ? 1 : ((a > b) ? -1 : 0));
33
	}
34
} );