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

@libregrid/server-side-selection

v1.3.4

Published

Server-side selection for AG Grid Community server-side row model grids — part of LibreGrid

Downloads

627

Readme

@libregrid/server-side-selection

Maintain a selection across pages, filters, and groups in a server-side grid. The browser holds a compact selection specification and flags for loaded rows. Your provider stores and evaluates the selection, including persistence across sessions when implemented by your backend.

Documentation and examples

Install

npm install "ag-grid-community@^36.1.0" @libregrid/server-side-selection

Requires ag-grid-community >=36.1.0 <37 as a peer dependency. @libregrid/server-side-row-model (and @libregrid/core) are installed automatically.

Usage

Supply a ServerSideSelectionProvider backed by your application and a server-side datasource. This setup function deliberately accepts both: the package does not supply a persistence service or a database query endpoint. See the live example for a complete browser mock of the provider contract.

<div id="grid" style="height: 400px"></div>
<div id="footer"></div>
import {
  AllCommunityModule,
  ModuleRegistry,
  createGrid,
  type IServerSideDatasource,
} from 'ag-grid-community';
import { ServerSideRowModelModule } from '@libregrid/server-side-row-model';
import {
  ServerSideSelectionModule,
  type ServerSideSelectionProvider,
} from '@libregrid/server-side-selection';

interface Trade {
  id: string;
  quantity: number;
}

ModuleRegistry.registerModules([
  AllCommunityModule,
  ServerSideRowModelModule,
  ServerSideSelectionModule,
]);

export function createTradeGrid(
  provider: ServerSideSelectionProvider,
  datasource: IServerSideDatasource<Trade>,
  tabId: string,
) {
  return createGrid<Trade>(document.querySelector<HTMLElement>('#grid')!, {
    columnDefs: [{ field: 'id' }, { field: 'quantity' }],
    rowModelType: 'serverSide',
    rowSelection: { mode: 'multiRow', selectAll: 'currentPage' },
    getRowId: ({ data }) => data.id,
    serverSideDatasource: datasource,
    ssrmSelection: {
      provider,
      gridId: 'trades',
      tabId,
      onReady: (service) => {
        service.attachFooter(document.querySelector<HTMLElement>('#footer')!);
      },
    },
  });
}

Choose stable gridId and tabId values if the selection should survive reloads. Use distinct tab IDs for independent selections. These identifiers are storage keys, not authorization: the backend must scope reads and writes to the caller.

Use the rowSelection configuration for checkboxes. Also setting the deprecated checkboxSelection column property creates duplicate checkbox controls.

Provider contract

The provider is the only durable truth. All calls are keyed by {gridId, tabId} so open tabs own independent selections.

| Method | Purpose | | ------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | getSpec({gridId, tabId}) | Return the current spec: { terms, selectedCount }. terms is the capture order of all (filter) and group (route) terms; selectedCount is the server-side total. | | applyOps({gridId, tabId, ops}) | Apply a batch of ops atomically (server-side). Ops are small — at most one filter model, one group route, or one cache-sized id batch. | | resolveSelected({gridId, tabId, rowIds, groupRoutes}) | Evaluate the spec for a batch of loaded rows. rowIds are getRowId values; groupRoutes are getSsrmRoute arrays serialized as \|-joined strings. Return a map of each sent key to its selected state; missing keys default to false. |

Resolve membership for the requested loaded rows without materializing the entire selected dataset in the browser. Store specifications, additions, and exceptions on your backend and apply each operation batch atomically.

Ops

| Op | Effect | | --------------------------------- | ------------------------------------------------------------------------------------ | | selectAll {filter} | Append the all term for filter; the server clears the in-scope exceptions first. | | deselectAll | Clear every term, exception, and addition. | | select {ids} / deselect {ids} | Row-level additions / exceptions. | | selectGroup {route} | Append the group term for route; clears the route's exceptions. | | deselectGroup {route} | A route exception. |

Selection behavior

  • Terms accumulate. Selecting under one filter, then another, keeps both selections (union of terms).
  • Survive filter changes. Clearing or changing filters never touches the selection; the spec is filter-independent.
  • Exceptions override terms. A deselected row/group stays deselected even if a later term would match it.
  • Select All (filtered). Clears the in-scope exceptions and appends the all term.
  • Groups are atomic. Selecting any row under a group (or the group itself) selects/deselects the whole group route.
  • "Show All Selected". Toggling the footer's view makes the selection the dataset (pagination total = selected count). Filters still apply on top. The datasource must implement the selection-view query described below.
  • Header checkbox is viewport-only. With selectAll: 'currentPage' the header checkbox checks/unchecks the visible viewport; spec-level select-all/deselect-all live in the footer.

The selection-view datasource contract

When the user activates Show All Selected, the package flips the grid option ssrmSelectionViewActive to true and calls refreshServerSide(). Your serverSideDatasource should read that option (via the grid) and, while it is true, constrain its query to selected(spec) AND filterModel and report rowCount as that intersection. The package never snapshots or restores your filters. Deactivating the view flips the option back to false and refreshes.

API

| Export | Purpose | | ---------------------------- | -------------------------------------------------------------------------------------------- | | ServerSideSelectionModule | Registers the SSRM selectionSvc bean and the feature service. | | ServerSideSelectionService | The row-model-specific selection service (extends community BaseSelectionService). | | SsrmSelectionService | The feature service: op capture, spec lifecycle, hydration, footer, selection view. | | ssrmSelectionCss | Styles for the service-built footer (also injected by the module). | | getSsrmRoute(node) | (from @libregrid/server-side-row-model) A node's group route, or undefined for a leaf. |

SsrmSelectionService methods: attachFooter, detachFooter, selectAllFiltered, deselectAll, enterViewMode, exitViewMode, toggleViewMode, isViewActive, getSpec, refresh. The grid also gains api.refreshSsrmSelection().

Angular

Use the same column definitions and grid options with ag-grid-angular. Register the modules shown above through provideLibreGrid from @libregrid/angular. See the Angular setup for a complete component and bootstrap example.

License

MIT — see LICENSE and NOTICE. LibreGrid is an independent project and is not affiliated with, endorsed by, or sponsored by AG Grid Ltd.