In a grid show the selected items first

Hi all,

Is it possible In a grid to show the selected items first ?

any hint?


You could try to use a selection listener, create a new collection, apply it to the grid, then refresh the grid. I don’t think the framework has a built in functionality for this.

Thanks, the grid lazy load the data, i think the grid should manage the order for the selected rows

I’m not sure which behavior you want. If you want to have the selected rows on top, does this mean a user select a row that will be directly moved to the top?

Hi, yes this is exactly what I want to achieve

:wave: It should be simple with in memory data but it could be tricky with lazy loading as you have to “shift” all offsets/limits per query. Imagine you’re fetching the first page. You have to append the selected items as first and iterate whole page to check if already this page contains some selected items. In that case you should remove them from the original positions. So you have to always artificially increase the limit (+ number of selected items - already encountered items). And you have to add more items instead the selected ones on the original positions to “complete” the page to satisfy the query limit.

Thank you Roman, as I thought it’s not a simple thing.