Skip to content

Commit 97e0ffa

Browse files
classix-odmportuga
authored andcommitted
fix(sorting): fixed the priority computing when unsorting using column menu action (#6427)
* fix(sorting): fixed the priority computing when unsorting using column menu action * reafactor(code style): Add spaces to organize it.
1 parent ded2c12 commit 97e0ffa

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/js/core/factories/GridColumn.js

+9
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,15 @@ angular.module('ui.grid')
869869
* @description Removes column from the grid sorting
870870
*/
871871
GridColumn.prototype.unsort = function () {
872+
//Decrease priority for every col where priority is higher than the removed sort's priority.
873+
var thisPriority = this.sort.priority;
874+
875+
this.grid.columns.forEach(function (col) {
876+
if (col.sort && col.sort.priority !== undefined && col.sort.priority > thisPriority) {
877+
col.sort.priority -= 1;
878+
}
879+
});
880+
872881
this.sort = {};
873882
this.grid.api.core.raise.sortChanged( this.grid, this.grid.getColumnSorting() );
874883
};

0 commit comments

Comments
 (0)