Sidebar

Columns, filters, sort, query, views, data integrity and themes in one panel beside the grid, plus panels of your own.

The sidebar is an icon rail beside the grid with one panel open at a time. The grid core draws it, so it follows the grid's theme and works the same in every adapter.

<Grid
	rows={rows}
	columns={columns}
	sidebar={{
		panels: ['columns', 'filters', 'sort', 'query', 'views'],
		position: 'right', // or 'left'
		width: 300,
	}}
	initialState={{ sidebarPanel: 'columns' }} // the panel open at first
/>

Open and close panels from code with api.setState({ sidebarPanel: id }), api.setState({ sidebarPanel: null }) and api.setState({ sidebarPanel: api.getState().sidebarPanel === id ? null : id }); the open panel is api.getState().sidebarPanel. The rail shows how many filters, sorts and query conditions are active. Arrow keys move between rail buttons and Escape closes the panel.

Built-in panels

PanelWhat it does
columnsRow grouping (drop a column on it, drag the pills to reorder, subtotals, sticky headers); every column in its lane: show / hide, drag to reorder, pin
filtersEvery filterable column with its filter editor, the same one as the header funnel; a collapsed section summarizes its filter
sortThe sort rules in priority order: drag (or ↑ / ↓) to reorder, flip direction, add a column from a searchable list
queryConditions across columns in nested All / Any groups, edited as a draft and applied with Apply
viewsThe open view (save changes, revert, save as new) and the named views; with persistence, Remember layout
dataIntegrityThe grid's status with Run checks; issues by severity, the diff (accept a change), conflicts (keep mine / take theirs)
themesA card per built-in theme

Views

The Views panel lists the grid's views and shows whether the grid still shows the open one as defined: Save changes sends it to the view's owner (a refusal or a newer definition is said in the panel), Revert shows it as defined again, and Save as new names what the grid shows. Each view opens in one click; its menu sets the default view, renames, duplicates and deletes (the app's own views are its to rename and delete). Without a view store or storage, views made here last the session, and the panel says so.

Panels of your own

A panel is an id, a label, an icon (SVG markup on a 24 × 24 view box) and either a React component or a DOM panel. The panel gets the grid api, a slot for actions in its header, close(), and mountFilterEditor to embed a column's filter editor.

import type { GridApi, SidebarPanelDef } from '@witbybit/wit-grid-react';

declare function NotesPanel(props: { api: GridApi<Order> }): JSX.Element;

const notes: SidebarPanelDef<Order> = {
	id: 'notes',
	label: 'Notes',
	icon: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M4 4h16v16H4z"/><path d="M8 9h8M8 13h6"/></svg>',
	renderPanel: ({ api }) => <NotesPanel api={api} />,
};

<Grid rows={rows} columns={columns} sidebar={{ panels: ['columns', notes] }} />;

The component renders inside the grid's React tree, so hooks such as useGridWatch work. When the config changes (say the panel reads new props), the open panel updates in place.

Edit on GitHub

Last updated on

On this page