From 49dce163798b29c484b6c8cff5a87906581003fe Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 19 Oct 2017 11:37:16 +0200 Subject: [PATCH 1/2] fix(sorting): fixed the priority computing when unsorting using column menu action --- src/js/core/factories/GridColumn.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/js/core/factories/GridColumn.js b/src/js/core/factories/GridColumn.js index 418b088449..3f62ffdbf6 100644 --- a/src/js/core/factories/GridColumn.js +++ b/src/js/core/factories/GridColumn.js @@ -869,6 +869,13 @@ angular.module('ui.grid') * @description Removes column from the grid sorting */ GridColumn.prototype.unsort = function () { + //Decrease priority for every col where priority is higher than the removed sort's priority. + var thisPriority = this.sort.priority; + this.grid.columns.forEach(function (col) { + if (col.sort && col.sort.priority !== undefined && col.sort.priority > thisPriority) { + col.sort.priority -= 1; + } + }); this.sort = {}; this.grid.api.core.raise.sortChanged( this.grid, this.grid.getColumnSorting() ); }; From f6aeb4b5e78474eedb58aef764be03dea8be8eb1 Mon Sep 17 00:00:00 2001 From: Marcelo Sauerbrunn Portugal Date: Mon, 13 Nov 2017 14:27:11 -0500 Subject: [PATCH 2/2] reafactor(code style): Add spaces to organize it. --- src/js/core/factories/GridColumn.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/js/core/factories/GridColumn.js b/src/js/core/factories/GridColumn.js index 3f62ffdbf6..86994fd3d3 100644 --- a/src/js/core/factories/GridColumn.js +++ b/src/js/core/factories/GridColumn.js @@ -871,11 +871,13 @@ angular.module('ui.grid') GridColumn.prototype.unsort = function () { //Decrease priority for every col where priority is higher than the removed sort's priority. var thisPriority = this.sort.priority; + this.grid.columns.forEach(function (col) { if (col.sort && col.sort.priority !== undefined && col.sort.priority > thisPriority) { col.sort.priority -= 1; } }); + this.sort = {}; this.grid.api.core.raise.sortChanged( this.grid, this.grid.getColumnSorting() ); };