mirror of
https://github.com/DataTables/DataTables.git
synced 2025-02-27 00:54:15 +01:00
Fix example: DOM sorting plug-in wasn't sorting correctly for numeric values
* This fixes DataTables/DataTables #352
This commit is contained in:
parent
73ed6c4725
commit
8e71c39929
@ -1 +1 @@
|
||||
005ac1a540dfef114feaefe0968d647da0ae87c1
|
||||
ad3a2ea74090ef0721f2e74f2e14ea883739c05c
|
||||
|
@ -27,6 +27,14 @@ $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
|
||||
} );
|
||||
}
|
||||
|
||||
/* Create an array with the values of all the input boxes in a column, parsed as numbers */
|
||||
$.fn.dataTable.ext.order['dom-text-numeric'] = function ( settings, col )
|
||||
{
|
||||
return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
|
||||
return $('input', td).val() * 1;
|
||||
} );
|
||||
}
|
||||
|
||||
/* Create an array with the values of all the select options in a column */
|
||||
$.fn.dataTable.ext.order['dom-select'] = function ( settings, col )
|
||||
{
|
||||
@ -48,7 +56,7 @@ $(document).ready(function() {
|
||||
$('#example').dataTable( {
|
||||
"columns": [
|
||||
null,
|
||||
{ "orderDataType": "dom-text", "type": "numeric" },
|
||||
{ "orderDataType": "dom-text-numeric" },
|
||||
{ "orderDataType": "dom-text" },
|
||||
{ "orderDataType": "dom-select" }
|
||||
]
|
||||
@ -1650,6 +1658,14 @@ $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
|
||||
} );
|
||||
}
|
||||
|
||||
/* Create an array with the values of all the input boxes in a column, parsed as numbers */
|
||||
$.fn.dataTable.ext.order['dom-text-numeric'] = function ( settings, col )
|
||||
{
|
||||
return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
|
||||
return $('input', td).val() * 1;
|
||||
} );
|
||||
}
|
||||
|
||||
/* Create an array with the values of all the select options in a column */
|
||||
$.fn.dataTable.ext.order['dom-select'] = function ( settings, col )
|
||||
{
|
||||
@ -1671,7 +1687,7 @@ $(document).ready(function() {
|
||||
$('#example').dataTable( {
|
||||
"columns": [
|
||||
null,
|
||||
{ "orderDataType": "dom-text", "type": "numeric" },
|
||||
{ "orderDataType": "dom-text-numeric" },
|
||||
{ "orderDataType": "dom-text" },
|
||||
{ "orderDataType": "dom-select" }
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user