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] Add option to explicitly set the initial sorting priority #1945

Open
jariberi opened this issue Jan 15, 2018 · 7 comments
Open

[grid] Add option to explicitly set the initial sorting priority #1945

jariberi opened this issue Jan 15, 2018 · 7 comments
Labels
enhancement New feature or request vaadin-grid
Projects

Comments

@jariberi
Copy link

Is there any way to explicitly set the initial ordering priority/sorting in vaadin grid columns?

@jariberi jariberi changed the title Is there any way to explicitly set the initial ordering priority? Is there any way to explicitly set the initial sorting priority? Jan 15, 2018
@web-padawan
Copy link
Member

web-padawan commented Jan 15, 2018

You can set the direction attribute on the <vaadin-grid-sorter> element. But actually the sorters array is populating in reverse direction because of this line. See this jsfiddle for demo and note how the "First name" order changes once you click on the correspondent header cell.

Do I understand correctly that you expect the API to be able to configure how these values of the sorters are getting applied by default? Would you expect it to be a numeric index?

@jariberi
Copy link
Author

jariberi commented Jan 15, 2018

Yes, a numeric index would be great. Maybe in each <vaadin-grid-sorter> element and the order like a normal JS array...

@karsten-eger
Copy link

I stumbled across this issue as well last week. Would be nice to have an option for this. The priority could even be the index in the sortOrder array.

@HJK181
Copy link

HJK181 commented Feb 21, 2018

It also would be nice to have the possibility to control which sorting direction will be applied on the first click of a column. So the column is not sorted initially but on first click I want it to be sorted in desc order not in asc order.

I don't see any possibility to achieve this yet.

@jariberi
Copy link
Author

Any update?

@sgoodrow
Copy link

sgoodrow commented Aug 20, 2018

I would also like this, but I think the sorting algorithm would need to be changed for both multi sort and single sort because of the way initialization occurs on each column. That, or an added hook after connection is done which allows specification of default sort orders.

The problem is that the sort algorithm re-assigns the order based on the array index, and adding elements to the array takes place in a static order (column order), so the default sort order would always be the column order.

POC fork here

This became a rabbit hole. Sorting algorithm changes work, but the display order number can be inflated with clever clicking.

@fireplace009
Copy link

Any update about this ?

I have the same request, after a page refresh, the ordering is no longer displayed correctly.
If we could specify the order just like we can with the direction. Please add asap :/

For example:
<vaadin-grid-sorter on-tap="_sort" direction="[[_direction(header.name)]]" order="[[_order(header)]]" path="[[header.name]]" >

Bug screenshot:

My grid is showing like this
image

Then the user does a page Refresh (F5)
image

(the direction is correct, the sort order is not)

@vaadin-bot vaadin-bot transferred this issue from vaadin/vaadin-grid May 19, 2021
@vaadin-bot vaadin-bot added enhancement New feature or request vaadin-grid labels May 19, 2021
@web-padawan web-padawan changed the title Is there any way to explicitly set the initial sorting priority? [grid] Add option to explicitly set the initial sorting priority May 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request vaadin-grid
Projects
No open projects
vaadin-core
  
📬  Inbox
Development

No branches or pull requests

7 participants