From 5d4410631322105b5c8e934801c355b3f0153869 Mon Sep 17 00:00:00 2001 From: Mont Rothstein Date: Fri, 25 Sep 2015 09:55:25 -0700 Subject: [PATCH] Added hold-order option to draw() and ignoreSortAndFilter flag to _fnReDraw() so that data may be updated without re-flowing the table. --- js/api/api.draw.js | 5 +++++ js/core/core.draw.js | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/js/api/api.draw.js b/js/api/api.draw.js index 312df3514..55f57dcd7 100644 --- a/js/api/api.draw.js +++ b/js/api/api.draw.js @@ -8,6 +8,11 @@ _api_register( 'draw()', function ( paging ) { if ( paging === 'page' ) { _fnDraw( settings ); } + // To update the data without re-sorting, re-filtering, or changing the page, the hold-order option was added. + // This sets the ignoreSortAndFilter falg on _fnReDraw. + else if (paging === 'hold-order') { + _fnReDraw(settings, true, true); + } else { if ( typeof paging === 'string' ) { paging = paging === 'full-hold' ? diff --git a/js/core/core.draw.js b/js/core/core.draw.js index a175fc6a1..e9cc33f49 100644 --- a/js/core/core.draw.js +++ b/js/core/core.draw.js @@ -449,14 +449,16 @@ function _fnDraw( oSettings ) * @param {object} oSettings dataTables settings object * @param {boolean} [holdPosition] Keep the current paging position. By default * the paging is reset to the first page + * @param {boolean} [ignoreSortAndFilter] Keep the rows as they are rather than + * resorting and filtering based on the table settings * @memberof DataTable#oApi */ -function _fnReDraw( settings, holdPosition ) +function _fnReDraw( settings, holdPosition, ignoreSortAndFilter ) { var features = settings.oFeatures, - sort = features.bSort, - filter = features.bFilter; + sort = ignoreSortAndFilter === true ? false : features.bSort, + filter = ignoreSortAndFilter === true ? false : features.bFilter; if ( sort ) { _fnSort( settings );