openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

sap.ui.table.Table: Row selections lost after sort or filter

Open AbhilashBiradar opened this issue 4 months ago • 1 comments

Describe the issue

When using sap.ui.table.Table with MultiSelectionPlugin or the built-in SelectionModelSelection, row selections are cleared on every sort or filter operation.

This is because selections are stored as row indices, which shift after sort/filter. There is no built-in mechanism to preserve selections across these operations.

Steps to reproduce

  1. Create a sap.ui.table.Table with MultiSelectionPlugin
  2. Select several rows
  3. Sort any column or apply a filter
  4. Selections are gone

Expected behavior

Row selections should be preserved after sort/filter. The selected rows — identified by their binding context, not their index — should remain selected even after their visual position changes.

Current workaround

I have implemented a community plugin that solves this by tracking binding context paths instead of row indices:

The plugin extends sap.ui.table.plugins.SelectionPlugin (the official base class) and overrides setSelected() / isSelected() to use context paths. It hooks into TableUtils.Hook.Keys.Table.RowsBound and binding change events to re-resolve selections after sort/filter.

Proposal

Consider either:

  1. Adding a preserveSelection property to MultiSelectionPlugin that enables context-path-based selection tracking natively
  2. Documenting the recommended approach for selection persistence in the plugin guide

Environment

  • UI5 version: 1.64+ (where SelectionPlugin was introduced)
  • Affects: sap.ui.table.Table, TreeTable, AnalyticalTable
  • Does not affect: sap.m.Table (different plugin architecture)

AbhilashBiradar avatar Jul 28 '26 02:07 AbhilashBiradar

Closing as duplicate of #439 which tracks the same issue since 2015. Added a community plugin solution there instead.

AbhilashBiradar avatar Jul 28 '26 02:07 AbhilashBiradar