From 4d4145a96ef9cd5c5d70f6b28375df616d999b5e Mon Sep 17 00:00:00 2001 From: "K. McCormick" Date: Fri, 17 Jul 2020 22:36:57 -0400 Subject: [PATCH] Adding type dom-text-numeric type that is mentioned in the manual and plugins but doesn't seem to be in the repo. --- sorting/custom-data-source/dom-text-numeric.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 sorting/custom-data-source/dom-text-numeric.js diff --git a/sorting/custom-data-source/dom-text-numeric.js b/sorting/custom-data-source/dom-text-numeric.js new file mode 100644 index 0000000..df3b686 --- /dev/null +++ b/sorting/custom-data-source/dom-text-numeric.js @@ -0,0 +1,16 @@ +/** + * Read information from a column of input (type number) elements and return an + * array to use as a basis for sorting. + * + * @summary Sorting based on the values of `dt-tag input` elements in a column. + * @name Input element data source + * @requires DataTables 1.10+ + * @author [Allan Jardine](http://sprymedia.co.uk) + */ + +$.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; + } ); +}