| 8 |
lars |
1 |
/**
|
|
|
2 |
* This sorting plug-in allows for HTML tags with numeric data. With the 'html'
|
|
|
3 |
* type it will strip the HTML and then sorts by strings, with this type it
|
|
|
4 |
* strips the HTML and then sorts by numbers. Note also that this sorting
|
|
|
5 |
* plug-in has an equivalent type detection plug-in which can make integration
|
|
|
6 |
* easier.
|
|
|
7 |
*
|
|
|
8 |
* DataTables 1.10+ has HTML numeric data type detection and sorting abilities
|
|
|
9 |
* built-in. As such this plug-in is marked as deprecated, but might be useful
|
|
|
10 |
* when working with old versions of DataTables.
|
|
|
11 |
*
|
|
|
12 |
* @name Numbers with HTML
|
|
|
13 |
* @summary Sort data which is a mix of HTML and numeric data.
|
|
|
14 |
* @deprecated
|
|
|
15 |
* @author [Allan Jardine](http://sprymedia.co.uk)
|
|
|
16 |
*
|
|
|
17 |
* @example
|
|
|
18 |
* $('#example').dataTable( {
|
|
|
19 |
* columnDefs: [
|
|
|
20 |
* { type: 'num-html', targets: 0 }
|
|
|
21 |
* ]
|
|
|
22 |
* } );
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
|
|
|
26 |
"num-html-pre": function ( a ) {
|
|
|
27 |
var x = String(a).replace( /<[\s\S]*?>/g, "" );
|
|
|
28 |
return parseFloat( x );
|
|
|
29 |
},
|
|
|
30 |
|
|
|
31 |
"num-html-asc": function ( a, b ) {
|
|
|
32 |
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
|
|
|
33 |
},
|
|
|
34 |
|
|
|
35 |
"num-html-desc": function ( a, b ) {
|
|
|
36 |
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
|
|
|
37 |
}
|
|
|
38 |
} );
|