Sort number on header displaying wrong value
When I sort a column by clicking on headers 1 is displayed to indicate sort order. Shift clicking on another column and 2 on that. Now if I continue to shift click on first column that I sorted earlier (marked with label 1), after one click 1 is removed and after another click it is labeled with 3. Now I have two columns labeled 2 and 3 while 1 is missing.
One would expect that it should retain the number or decrease the other numbers by 1 before adding a label.
Can you please make a plunkr that shows this behaviour?
Here it is http://plnkr.co/edit/i4HRAaLr9RhkwWM5ZTWc?p=preview. I am using the same example from the ui-grid tutorial.
To replicate the issue sort the table by 'Gender', now shift click on "Name" to sort it. At this stage 'Gender' is tagged 1 and 'Name' is tagged 2. Now try to sort "Gender" again but do it by holding Shift. After few clicks "Gender" will be tagged 3 and there is no 1.
Also if you continue Shift clicking 'Name' it will get 4.
The problem seems to be function getNextColumnSortPriority at Grid.js.
This function now looks for the greatest column priority and then returns that value + 1.
A better version would find the least unused priority.
A further improvement would be to edit sortColumn function and lower the priority af any previously prioritized column whose value was higher then the one the user edited.
Is there any word when this is will be fixed, beacuse I am using it and I have a defect logged for this.
problem still exists -- even on the UI Grid home page
on the basic example grid . Use the arrow menu on the "Name" column Set it to Sort Ascending
Use the arrow menu on the "Gender" column Set it to Sort Descending
Use the arrow menu on the "Name" column Set it to Sort Descending. Notice the count is incremented incorrectly. It is easy to really mess up the internal accounting by playing with the sort directions on multiple columns
hint : if you have only one number to work with , then refactor the code to use a sign ( + or - ) and the priority to designate sort and priority.
hence a sortState of { Gender: -3 } implies that the Gender column is the third priority field to be sorted in a descending order.
Of course removing sorted columns mean you have to do accounting and rework the numbers ( column.sort.priority I think it is? )
Yes, @mattmutt there's a ticket for the column.sort.priority recalculation out there too: https://github.com/angular-ui/ui-grid/issues/4196