Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preventing re-sort and re-filter when updating data #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions js/api/api.draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' ?
Expand Down
8 changes: 5 additions & 3 deletions js/core/core.draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down