Grid sort modes #8172
Labels
enhancement
New feature or request
needs discussion
No decision yet, discussion needed
refactor
Internal improvement
vaadin-grid
Describe your motivation
As was mentioned before at:
sorting of columns are not intuitive and developers doesn't have much options to handle it. One of the efforts to meet expectations was made at web-components!4089 by providing
MultiSortPriority
. But it solves only part of the cases.Not saying that the one of the features requested was not implemented as intended from the beginning. Correct me if I wrong, but it seems that for both modes (i.e.
APPEND
andPREPEND
) changing of sort direction is always changes the priority regardless of whether the column being sorted before or not. At least, according to the javadocs, I expected that usingAPPEND
mode the sort priority will not be affected for the already sorted column:For exampole, if I have three columns sorted as follows:
Switching sort direction for the
Foo
column will results in:While I'm expecting it will preserve its priority:
Anyway, the above solution doesn't cover all the possible bussines cases. I suggest to extend/reconsider the approach to take into account following concepts:
PREPEND
,APPEND
)UPDATE
,PRESERVE
)Order mode
This concept defines where the new sorted columns should go: start of the list (
PREPEND
) or end of the list (APPEND
). It is already implemented.Priority mode
This concept defines how priority should change for already sorted columns: should column goes to the start/end of the list (
UPDATE
) or should it stay on the current position (PRESERVE
). For the new sorted columns this has no effect and they just follows order mode.Direction mode
This concept is a bit tricky, but it is a result of the priority mode concept. For now, when you change sort derections they are cycling as foliows:
The problem is that when I have a column that have sort direction
DESC
I can't switch it to theASC
without going through theNONE
(neutral) value. Neutral value implies the sort order will be removed from the sort order list completely and when I come back to theASC
value the column will be evaluated as a new sort column and will go to the start/end of the list. To solve it we need to appy direction cycling mode without neutral value:See also web-components#1374, web-components#2018
As an option it can be solved by providing users a way to select exact derection they need without cycling. I suppose it was not done like that to be complient with the smart devices UI.
Describe the solution you'd like
Update grid column API to support described modes.
Modes indication can be done using a separate enum parameters, or using old-school bit mask approach to be able to mix constants together using one parameter.
Describe alternatives you've considered
No response
Additional context
Checked current behavior using
24.4.12
The text was updated successfully, but these errors were encountered: