From b7915d7cf66747aeaa3c05aba8721b5141b7a54b Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Sun, 26 May 2013 10:55:07 +0100 Subject: [PATCH] New: Initialisation option - sortMulti. Allow / disallow multi-coloumn sorting - Multi-coloumn sorting might not be a feature that everyone wants, so the ability to disable it is added in this commit. - This fixes issue #13. --- media/src/core/core.constructor.js | 1 + media/src/core/core.sort.js | 2 +- media/src/model/model.defaults.js | 20 ++++++++++++++++++++ media/src/model/model.settings.js | 8 ++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/media/src/core/core.constructor.js b/media/src/core/core.constructor.js index 05b449e1..c52d5022 100644 --- a/media/src/core/core.constructor.js +++ b/media/src/core/core.constructor.js @@ -103,6 +103,7 @@ _fnMap( oSettings.oFeatures, oInit, "bPaginate" ); _fnMap( oSettings.oFeatures, oInit, "bLengthChange" ); _fnMap( oSettings.oFeatures, oInit, "bFilter" ); _fnMap( oSettings.oFeatures, oInit, "bSort" ); +_fnMap( oSettings.oFeatures, oInit, "bSortMulti" ); _fnMap( oSettings.oFeatures, oInit, "bInfo" ); _fnMap( oSettings.oFeatures, oInit, "bProcessing" ); _fnMap( oSettings.oFeatures, oInit, "bAutoWidth" ); diff --git a/media/src/core/core.sort.js b/media/src/core/core.sort.js index e6955e1f..3c00c845 100644 --- a/media/src/core/core.sort.js +++ b/media/src/core/core.sort.js @@ -237,7 +237,7 @@ function _fnSortAttachListener ( settings, attachTo, colIdx, callback ) var nextSort; // If the shift key is pressed then we are multiple column sorting - if ( e.shiftKey ) { + if ( e.shiftKey && settings.oFeatures.bSortMulti ) { // Are we already doing some kind of sort on this column? var curr = _pluck( sorting, '0' ); var idx = $.inArray( colIdx, curr ); diff --git a/media/src/model/model.defaults.js b/media/src/model/model.defaults.js index b0846b39..5d1a0f48 100644 --- a/media/src/model/model.defaults.js +++ b/media/src/model/model.defaults.js @@ -743,6 +743,26 @@ DataTable.defaults = { "bSort": true, + /** + * Enable or display DataTables' ability to sort multiple columns at the + * same time (activated by shift-click by the user). + * @type boolean + * @default true + * + * @dtopt Options + * @name DataTable.defaults.sortMulti + * + * @example + * // Disable multiple column sorting ability + * $(document).ready( function () { + * $('#example').dataTable( { + * "sortMulti": false + * } ); + * } ); + */ + "bSortMulti": true, + + /** * Allows control over whether DataTables should use the top (true) unique * cell that is found for a single column, or the bottom (false - default). diff --git a/media/src/model/model.settings.js b/media/src/model/model.settings.js index f5be63ad..46d63284 100644 --- a/media/src/model/model.settings.js +++ b/media/src/model/model.settings.js @@ -113,6 +113,14 @@ DataTable.models.oSettings = { */ "bSort": null, + /** + * Multi-column sorting + * Note that this parameter will be set by the initialisation routine. To + * set a default use {@link DataTable.defaults}. + * @type boolean + */ + "bSortMulti": null, + /** * Apply a class to the columns which are being sorted to provide a * visual highlight or not. This can slow things down when enabled since