Closed letrthang closed 1 year ago
On the MasterDetailDesignerView
columns are specified with addColumn(ValueProvider)
, so you have to configure them as sortable explicitly
grid.addColumn(SamplePerson::getFirstName).setHeader("First Name").setAutoWidth(true).setSortProperty("firstName");
On MasterDetailJavaView
instead the columns are defined by the name of the property, so the grid can automatically apply the sort function according to the type of property inferred by inspecting the type of bean explicitly specified when creating 'Grid'.
It is actually misleading that the downloaded code produces a different result from the online preview.
So I would say it is more a start.vaadin.com
issue than a flow or Grid issue
Edit:
setSortable(true)
makes the sorting indicator visible but it doesn’t work. Using setSortProperty("firstName")
makes it visible and it works
Thanks @alvarezguille for pointing out
oh, thanks for sharing. I tried setSortable(true)
and it doesn't work. and wonder setSortProperty("firstName")
will work.
so still a bug :)). Need to fix setSortable(true)
It is not a bug.
As state in the documentation, setSortable()
is used to enable or disable column sorting and toggle the sorter element on and off.
To actually apply sort, you should use setSortProperty
, setComparator
or setSortOrderProvider
.
Here's the relevant docs: https://vaadin.com/docs/latest/components/grid/flow/#column-sorting https://vaadin.com/docs/latest/components/grid/flow/#enabling-and-disabling-column-sorting
I apologize for providing wrong information with my first comment.
Thanks for clarification, then only need fix on start.vaadin.com
Thanks for clarification, then only need fix on start.vaadin.com
Thanks for reporting. I'm closing this one, as the issue has been internally notified to the team
Transfer to starters repo, to check if demo project should be updated
Description of the bug
Just take example from starter. Sorting is not working using designer implementation.
code: https://github.com/letrthang/vaadin23-flow-pro-components/blob/main/src/main/java/com/example/application/views/masterdetaildesigner/MasterDetailDesignerView.java
https://github.com/letrthang/vaadin23-flow-pro-components/blob/main/frontend/views/masterdetaildesigner/master-detail-designer-view.ts
Note: pure java still works: https://github.com/letrthang/vaadin23-flow-pro-components/blob/main/src/main/java/com/example/application/views/masterdetailjava/MasterDetailJavaView.java
Expected behavior
can sort
Minimal reproducible example
https://github.com/letrthang/vaadin23-flow-pro-components
Versions