Subversion-Projekte lars-tiefland.faltradxxs.de

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
2 lars 1
/**
2
 * Sort by priority through an enumerated list. In this case the words _High_,
3
 * _Medium_ and _Low_ are used and thus sorted in priority order. This works
4
 * by converting the works to a numerical value and then sorting based on that
5
 * value.
6
 *
7
 *  @name enum
8
 *  @summary Sort an enumerated list of options
9
 *  @author [Allan Jardine](http://sprymedia.co.uk)
10
 *
11
 *  @example
12
 *    $('#example').dataTable( {
13
 *       columnDefs: [
14
 *         { type: 'enum', targets: 0 }
15
 *       ]
16
 *    } );
17
 */
18
 
19
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
20
	"enum-pre": function ( a ) {
21
		// Add / alter the switch statement below to match your enum list
22
		switch( a ) {
23
			case "High":   return 1;
24
			case "Medium": return 2;
25
			case "Low":    return 3;
26
			default:       return 4;
27
		}
28
	},
29
 
30
	"enum-asc": function ( a, b ) {
31
		return ((a < b) ? -1 : ((a > b) ? 1 : 0));
32
	},
33
 
34
	"enum-desc": function ( a, b ) {
35
		return ((a < b) ? 1 : ((a > b) ? -1 : 0));
36
	}
37
} );