Skip to content
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

Grid sort modes #8172

Open
ijioio opened this issue Nov 19, 2024 · 0 comments
Open

Grid sort modes #8172

ijioio opened this issue Nov 19, 2024 · 0 comments
Labels
enhancement New feature or request needs discussion No decision yet, discussion needed refactor Internal improvement vaadin-grid

Comments

@ijioio
Copy link

ijioio commented Nov 19, 2024

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 and PREPEND) 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 using APPEND mode the sort priority will not be affected for the already sorted column:

/**
 * Whenever an unsorted column is sorted, it gets added at the end of
 * the sort order, after all the previously sorted columns. When the
 * sort direction of a column is changed by the user, the priority for
 * all the sorted columns remains unchanged.
 */
APPEND

For exampole, if I have three columns sorted as follows:

  • Foo ▲ (1)
  • Bar ▲ (2)
  • Baz ▲ (3)

Switching sort direction for the Foo column will results in:

  • Foo ▼ (3)
  • Bar ▲ (1)
  • Baz ▲ (2)

While I'm expecting it will preserve its priority:

  • Foo ▼ (1)
  • Bar ▲ (2)
  • Baz ▲ (3)

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:

  1. Order mode: how to handle newly sorted columns (PREPEND, APPEND)
  2. Priority mode: how to handle already sorted columns (UPDATE, PRESERVE)
  3. Direction mode: how to handle direction cycling

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:

... > ASC > DESC > NONE > ...

The problem is that when I have a column that have sort direction DESC I can't switch it to the ASC without going through the NONE (neutral) value. Neutral value implies the sort order will be removed from the sort order list completely and when I come back to the ASC 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:

... > ASC > DESC > ...

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

@yuriy-fix yuriy-fix added enhancement New feature or request refactor Internal improvement vaadin-grid needs discussion No decision yet, discussion needed labels Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs discussion No decision yet, discussion needed refactor Internal improvement vaadin-grid
Projects
None yet
Development

No branches or pull requests

2 participants