-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix(core): Sort Priority Zero Based #4807
fix(core): Sort Priority Zero Based #4807
Conversation
6fe0528
to
cca7734
Compare
This has a breaking change. It would be good to do a version bump to 3.1.0 after this is merged. |
@@ -1876,12 +1876,12 @@ angular.module('ui.grid') | |||
p = 0; | |||
|
|||
self.columns.forEach(function (col) { | |||
if (col.sort && col.sort.priority && col.sort.priority > p) { | |||
p = col.sort.priority; | |||
if (col.sort && col.sort.priority !== 'undefined' && col.sort.priority >= p) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here you should compare col.sort.priority
to undefined
and not 'undefined'
or typeof col.sort.priority !== 'undefined'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'll change that. I saw it like this somewhere else.
@JLLeitschuh can you fix the merge issues? I think we need to get this merged and released as soon as we can. thanks. |
Yea, I'll try to fix this today. |
cca7734
to
6d41f3d
Compare
Before sort priority was a mix of 0 and 1 based. You could create columns with a sort priority of zero but once the user clicked on a column to sort it its index would change to 1. There was no way for the sort index to return to 0 from within the grid's menus. This mix of 0 and 1 based sorting was confusing and created UI problems when displaying the sort index in the column header. Closes angular-ui#4685 BREAKING CHANGE: **GridOptions.columnDef.sort.priority** now expects the lowest value to be 0. The Grid Header will display a sort priority of 0 as 1. Using `if(col.sort.priority)` to determine if a column is sorted is no longer valid as `0 == false`. Saved grid objects may be affected by this.
6d41f3d
to
62dbcfe
Compare
fix(core): Sort Priority Zero Based
@@ -21,13 +21,13 @@ | |||
aria-label="{{getSortDirectionAriaLabel()}}"> | |||
<i | |||
ng-class="{ 'ui-grid-icon-up-dir': col.sort.direction == asc, 'ui-grid-icon-down-dir': col.sort.direction == desc, 'ui-grid-icon-blank': !col.sort.direction }" | |||
title="{{isSortPriorityVisible() ? i18n.headerCell.priority + ' ' + col.sort.priority : null}}" | |||
title="{{isSortPriorityVisible() ? i18n.headerCell.priority + ' ' + ( col.sort.priority + 1 ) : null}}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Grid.js line 1880 aren't you bumping up the sortPriority, so adding 1 again here would be incorrect?
Before sort priority was a mix of 0 and 1 based.
You could create columns with a sort priority of zero but once the user
clicked on a column to sort it its index would change to 1. There was no
way for the sort index to return to 0 from within the grid's menus.
This mix of 0 and 1 based sorting was confusing and created UI problems
when displaying the sort index in the column header.
Closes #4685
BREAKING CHANGE:
GridOptions.columnDef.sort.priority now expects the lowest value
to be 0.
The Grid Header will display a sort priority of 0 as 1.
Using
if(col.sort.priority)
to determine if a column is sorted is nolonger valid as
0 == false
.Saved grid objects may be affected by this.