npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ui5-plugin-persist-selection

v1.0.0

Published

SAP UI5 table plugin that preserves row selections across sort and filter operations

Readme

ui5-plugin-persist-selection

npm version license tests demo

▶ Live Demo — Select rows, sort or filter, selections persist.

A sap.ui.table.Table selection plugin that preserves row selections across sort and filter operations — by tracking binding context paths instead of row indices.


The Problem

Standard UI5 selection plugins (MultiSelectionPlugin, SelectionModelSelection) store selections as row indices. When a user sorts or filters the table, row indices shift — the selection is lost.

This is a well-known frustration in enterprise UI5 applications. This plugin solves it.


How It Works

PersistSelectionPlugin extends sap.ui.table.plugins.SelectionPlugin — the official plugin base class introduced in UI5 1.64. Instead of storing indices, it stores the binding context path of each selected row (/Products(1), /Orders(42), etc.).

Context paths are stable — they survive sort, filter, and pagination. After a sort or filter, the plugin re-resolves which visible rows are selected by matching their context paths.


Requirements

  • SAPUI5 / OpenUI5 >= 1.64.0 (when SelectionPlugin was introduced)
  • sap.ui.table.Table, sap.ui.table.TreeTable, or sap.ui.table.AnalyticalTable
  • Does not work with sap.m.Table

Installation

npm install ui5-plugin-persist-selection

Usage

JavaScript

sap.ui.require([
    "sap/ui/table/Table",
    "ui5-plugin-persist-selection/src/PersistSelectionPlugin"
], function (Table, PersistSelectionPlugin) {

    const oPlugin = new PersistSelectionPlugin({
        selectionMode: "MultiToggle",
        selectionChange: function (oEvent) {
            const aPaths = oEvent.getParameter("contextPaths");
            console.log("Selected paths:", aPaths);
            // aPaths remain stable after sort/filter
        }
    });

    const oTable = new Table({
        dependents: [oPlugin],
        columns: [ /* ... */ ],
        rows: { path: "/Products" }
    });
});

XML View

<table:Table
    xmlns:table="sap.ui.table"
    xmlns:plugins="com.abhilashbiradar"
    rows="{/Products}">
    <table:dependents>
        <plugins:PersistSelectionPlugin
            selectionMode="MultiToggle"
            selectionChange=".onSelectionChange"/>
    </table:dependents>
    <table:columns>
        <!-- columns -->
    </table:columns>
</table:Table>

API

Properties

| Property | Type | Default | Description | |---|---|---|---| | selectionMode | sap.ui.table.SelectionMode | MultiToggle | MultiToggle or Single | | limit | int | 0 | Max selectable rows. 0 = unlimited |

Events

| Event | Parameters | Description | |---|---|---| | selectionChange | contextPaths: string[], rowIndices: int[], trigger: string | Fired when selection changes. trigger is "user" or "sortFilter" |

Methods

| Method | Returns | Description | |---|---|---| | getSelectedContextPaths() | string[] | Stable context paths of selected rows | | getSelectedIndices() | int[] | Current row indices (shift after sort/filter) | | setSelectedContextPaths(paths) | void | Programmatically select by context path | | clearSelection() | void | Deselect all rows | | selectAll() | void | Select all visible rows | | getSelectedCount() | int | Number of selected rows | | PersistSelectionPlugin.findOn(oTable) | PersistSelectionPlugin | Find the plugin instance on a table |


vs MultiSelectionPlugin

| Feature | MultiSelectionPlugin | PersistSelectionPlugin | |---|---|---| | Selection survives sort | ✗ Cleared | ✓ Preserved | | Selection survives filter | ✗ Cleared | ✓ Preserved | | Works with OData V4 | ✓ | ✓ | | Works with JSON model | ✓ | ✓ | | Range selection (shift+click) | ✓ | ✓ | | Select All | ✓ | ✓ (visible rows) | | Selection limit | ✓ | ✓ | | Stable selection reference | index (unstable) | context path (stable) |


Contributing

Bug reports and feature requests → GitHub Issues

💬 Questions and ideas → GitHub Discussions


License

MIT © Abhilash Biradar