sap.ui.table.Table: Row selections cleared after applying a sort or filter
OpenUI5 version: latest
Browser/version (+device/version): all
Any other tested browsers/devices(OK/FAIL):
URL (minimal example if possible): http://jsbin.com/habapa/edit?html,js,output
User/password (if required and possible - do not post any confidential information here):
Steps to reproduce the problem:
- Select one or more rows in the table
- Click on a column header and select one of the sort options
- Note that the row selections are cleared
- Repeat the same and apply a filter (e.g. text) and note that the row selections are cleared again.
What is the expected result? Expected that if you're resorting a table, any row selections will be maintained after the sort. For filtering, it's expected that any selected rows that make it through the filter remain selected.
What happens instead? All row selections are cleared after a resort or filter.
Any other information? (attach screenshot if possible)
This works (currently) as designed (see here), because preserving the selection is not so easy to implement.
I fully agree that this would be a nice feature, but it is currently not planned from our side. I will keep this open as an enhancement for now.
Thanks for the info Matthias. The unfortunate reality is that most users likely expect this behavior, and so all OpenUI5 app creators that want to address this expectation need to tackle this "not so easy" task on their own in varying ways. Any additional consideration for this making it into the plan would be greatly appreciated.
I can fully understand you. I've forwarded your request. Let's see if it gets into the backlog in the future. @thomaskoetter we should make sure to update this issue once there is some progress going on.
All I'm trying to say is that most users expect table selections to remain in place after a sort or filter. And so anyone writing an OpenUI5 app would need to add in this support on their own. Which means alot of duplicate effort in researching/implementing a solution. Having this in the SDK would spare each developer of that and provide a consistent and tested solution.
Fully understood. Both use cases are valid. It's been added to the backlog, but there's no saying when it will make the cut.
Just checking to see if there's any realistic chance this will make it out of the backlog in the near future. This is an issue that keeps coming up from our consumers, and we'll need to come up with a solution if one isn't provided in the SDK.
Hello cmastandrea, i contacted the product owner for this team again to give a feedback.
Hi Matthias, Is this enhancement (Row selections cleared after applying a sort or filter) has been implemented in sap.ui.table,Table ?
Hi @venkymachineni i have extended this and solved issue. @matz3 I would love to contribute this feature.
Hi @simlin, is there any status update on this issue? I have the same problem, that my table looses the value of the checkboxes. I also noticed, that it already is implemented in the m.table.
Hi @crossfader92 , keeping the selection information after sort or filter needs a key based approach instead of an index based API. Or the new indices must be recalculated after sort or filter. For this the full information (data) must be available which is mostly only the case with ClientListBindings. So an "one selection API fits all cases" seems not to be the way forward. Therefore we started with the MultiSelectionPlugin to introduce a way to provide alternative selection behaviors more easily. We are not yet there to open it up for "external" plugins. But that's the idea for future plannings.
Hi Guys,
came across this by chance, because I had some handling issues with row selection.
I see that it is quite difficult to preserve the selection, especially in lazy loading scenarios. So. it would have to be handled by the dev who implements it.
However, in case of multi select I don't see an obvious way to re-apply the selection after update.
Would it make sense to implement a counterpart "sap.ui.table.setSelectedIndices" for the method "sap.ui.table.getSelectedIndices"?
Best, Pablo
Hi Pablo, there are the two methods "addSelectionInterval" and "setSelectionInterval". I think that's what you need :) I fixed the selection issue for me be redefining the onRowsUpdated method of sap.ui.table. But that's hopefully just a temporary solution. Regards, Kevin
Thanks for the hint @crossfader92, that's what I was looking for!
Sorry for chiming in, but isn't adding an extra column with a CheckBox and a binding to a model column a possible stand-in for using the multiselect mode for these kinds of use cases?
Just a thought as I ran into the same question today and solved it this way.
Backlog FIORITECHP1-14428
Hello we cross with this issue as well any progress or temporary solution other than getSelectedIndices, .setSelectionInterval methods?
For anyone still hitting this in 2026 — I've published a community plugin that solves this by tracking binding context paths instead of row indices:
- npm: ui5-plugin-persist-selection
- GitHub: AbhilashBiradar/ui5-plugin-persist-selection
- Live demo: https://abhilashbiradar.github.io/ui5-plugin-persist-selection/demo/index.html
It extends the official sap.ui.table.plugins.SelectionPlugin base class (available since UI5 1.64) and overrides setSelected() / isSelected() to use context paths. Works with OData and JSON models, supports MultiToggle and Single modes, and is compatible with all sap.ui.table.Table variants.
// Just add it as a dependent — no other config needed
oTable.addDependent(new PersistSelectionPlugin());
Selections survive sort, filter, and pagination. The selectionChange event returns contextPaths (stable across sort/filter) in addition to rowIndices.
Hello @AbhilashBirada
Thank you for the contribution.
The shown solution uses the same mechanism as the ResponsiveTable to remember the binding paths to keep the selection. This works well with client-side models (JSONModel), but it has weak points with ODataV2, mainly because contexts are not preserved on any model refresh.
For ODataV4, UI5 offers two dedicated plugins that leverage model capabilities to solve the sort topic and keep selected contexts alive during refresh:
- sap.ui.table.plugins.ODataV4MultiSelection (https://sdk.openui5.org/#/api/sap.ui.table.plugins.ODataV4MultiSelection) for multi-selection scenarios
- sap.ui.table.plugins.ODataV4SingleSelection (https://sdk.openui5.org/#/api/sap.ui.table.plugins.ODataV4SingleSelection) for single-selection scenarios
These plugins utilize ODataV4's model capabilities to maintain selection state across operations like sorting and refreshing. The same model functionality is also used by the ResponsiveTable in combination with ODataV4, providing a consistent approach across table types.
We recommend using these ODataV4-specific plugins for robust selection persistence when working with ODataV4 models.