Reputation: 146
I am using Vaadin 14 grid. This grid contains a number of columns. A few of them need to represent boolean values, hence we use a checkbox component inside that column. This is done by using grid.addComponentColumn
method. The text related columns a just added using grid.addColumn
Now we want to enable multisort on the grid. By default the sorting indicators (up/down arrow) in the header are shown for the text based columns but not for the boolean values .
After adding sorting to the boolean column /component column (addComponentColumn(...).setSortable(true)
the sorting indicators in the headers are shown, but the sorting itself is not performed when changing the sort direction (none / asc / desc) using the arrows in the header.
How can I make this work? Thanks in advance!
Upvotes: 0
Views: 630
Reputation: 8001
When you have custom logic for what's rendering in a column, then you also need to explicitly configure how sorting should be handled for that column.
If you're using in-memory data, then you do that using Column.setComparator
. If you're using a backend data source, then you should instead use Column.setSortProperty
and also ensure that the data provider actually considers the contents of Query.getSortOrders
.
You can see an example of this in practice at https://cookbook.vaadin.com/sort-with-renderer.
Upvotes: 2