Skip to content

Commit

Permalink
fix(sorting): fixed the priority computing when unsorting using colum…
Browse files Browse the repository at this point in the history
…n menu action (#6427)

* fix(sorting): fixed the priority computing when unsorting using column menu action

* reafactor(code style): Add spaces to organize it.
  • Loading branch information
classix-od authored and mportuga committed Nov 13, 2017
1 parent ded2c12 commit 97e0ffa
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/js/core/factories/GridColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,15 @@ 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() );
};
Expand Down

0 comments on commit 97e0ffa

Please sign in to comment.