From beaca38f30426c45d002724e1ff092bd30638a78 Mon Sep 17 00:00:00 2001 From: Somasekar-N Date: Mon, 20 Jul 2015 19:03:54 +0530 Subject: [PATCH] Update dom-select.js Added option to sort select list in a dataTable using selected text. --- sorting/custom-data-source/dom-select.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sorting/custom-data-source/dom-select.js b/sorting/custom-data-source/dom-select.js index 22774e3..d4be390 100644 --- a/sorting/custom-data-source/dom-select.js +++ b/sorting/custom-data-source/dom-select.js @@ -14,3 +14,15 @@ $.fn.dataTable.ext.order['dom-select'] = function ( settings, col ) return $('select', td).val(); } ); }; + +/** + * @summary Sort based on the selected text of the `dt-tag select` options in a column + * @author [Somasekar N](somasekar.cse@gmail.com) + */ + +$.fn.dataTable.ext.order['dom-select'] = function ( settings, col ) +{ + return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) { + return $('select :selected', td).val(); + } ); +};