Skip to content

Framework guide ​

The three wrappers (React, Vue 3, Angular) create the grid, pass options in, relay events out and clean up on destroy. That is all they do. Sorting, selection, editing and saving live in core, so Row selection and keyboard, Cell editing and Save changes in a batch apply to all three unchanged. Only what differs per framework is covered here. The tabs below are linked: pick one and every tab in the docs follows.

For React, Use with React adds stable options, syncing selection, sort and filter, component cells, Next.js, typing and 13 live examples.

For Vue, Use with Vue adds v-model, component cells, Nuxt, typing and 13 live examples.

There is no live demo, because the docs site uses the renderer without a framework. The complete code for the same screen in React, Vue, Angular and plain JavaScript is on The same screen in React, Vue and Angular. You can copy it and run it as it is.

Install ​

Each framework package takes react, vue or @angular/core as a peer dependency.

FrameworkPackageSupported versions
React@maxgrid/reactReact 18, 19
Vue@maxgrid/vueVue 3.4 and later
Angular@maxgrid/angularAngular 17+ (standalone)
bash
pnpm add @maxgrid/react @maxgrid/themes
ts
// Once, in the app entry
import '@maxgrid/themes/grid.css';

Each package re-exports the core types. Import GridOptions, ColumnDef and GridApi from the wrapper package instead of @maxgrid/core.

Pass options ​

Set the height on the component element itself (Grid, mx-grid). A height on an outer div alone is not passed down, so the grid grows and renders every row (Get started).

tsx
import { Grid, type GridOptions } from '@maxgrid/react';
import { useMemo, useState } from 'react';

interface Employee {
  id: number;
  name: string;
  department: string;
}

const columns = [
  { id: 'name', title: 'Name' },
  { id: 'department', title: 'Department' },
];

export function EmployeeGrid({ initial }: { initial: Employee[] }) {
  const [rows, setRows] = useState(initial);
  // Rebuilt only when rows changes, not on every render.
  const options = useMemo<GridOptions<Employee>>(() => ({ columns, rows, rowKey: 'id' }), [rows]);

  return <Grid style={{ height: 300 }} options={options} />;
}

setOptions runs only when the options reference changes. Mutating the object in place (options.rows.push(...)) keeps the same reference, so nothing happens. Pass a new object instead.

All three wrappers follow these rules.

  • Passing the same options object again does not call setOptions. Passing a new object makes core compare it property by property and apply only what changed.
  • Passing a whole new rows array is handled like setRows, and it clears the pending change log (Save changes in a batch). Make sure parent state does not push down a new array while unsaved changes exist.
  • Before you refresh from server data, check api.hasChanges() and only then build the new options.

Listen to events ​

The core event names are the ones in the Events table. The wrappers only change how the name is delivered.

tsx
<Grid
  options={options}
  onSortChanged={({ sortModel }) => console.log(sortModel)}
  onSelectionChanged={({ selectedKeys }) => setCount(selectedKeys.length)}
/>

Each event becomes a prop named on plus the capitalized event name (sortChanged becomes onSortChanged). The grid subscribes only to events that have a handler, and it always calls the latest function, so changing handlers never resubscribes. Inline arrow functions are fine. Without onScrolled, scrolling does no React work.

Angular [events] and change detection ​

In Angular, bringing an event into the Zone triggers one round of change detection. Keep three facts in mind.

  • Events enter the Zone only while (gridEvent) has a subscriber. With no subscriber, no change detection runs.
  • If you omit [events], every event is relayed. That includes scrolled, so change detection runs continuously while the user scrolls. List only the events you need, and the grid does not even subscribe to the rest.
  • [events] is read once, when the grid is created. Changing the array later does not add or remove subscriptions.

Get GridApi ​

This is how you call methods directly. The value is null before the grid exists and after it is destroyed.

tsx
import { Grid, useGridApi } from '@maxgrid/react';

export function Toolbar({ options }: { options: GridOptions<Employee> }) {
  const [api, gridRef] = useGridApi<Employee>();

  return (
    <>
      <button disabled={!api} onClick={() => api?.clearSelection()}>
        Clear selection
      </button>
      <Grid ref={gridRef} options={options} />
    </>
  );
}

The ref receives the GridApi. useGridApi() is a hook that returns [api, ref]. It rerenders once when the grid is created, so a button can use api. A useRef or a callback ref works too.

Handle selection, sort and filter state ​

Core owns selection, sort and filter. To keep sort direction or the selected count in app state too, read it from events. To change it, call GridApi.

The React wrapper supports uncontrolled use only. There are no controlled props such as selectedKeys or sortModel. Pushing a value back in would make the wrapper handle the exception setSelectedKeys can throw and break the loop of event, state, props and event again. That would turn the wrapper into business logic.

tsx
const [selected, setSelected] = useState<Array<string | number>>([]);

<Grid
  options={options}
  onSelectionChanged={({ selectedKeys }) => setSelected(selectedKeys)} // read
  onReady={({ api }) => api.setSelectedKeys([1, 2])} // set the first value
/>;

// write: api.setSelectedKeys([...]), api.setSortModel([...]), api.setFilterModel(...)

Show save status ​

Core does change tracking and saving (Save changes in a batch). The wrappers add only a helper for deciding whether the Save button is enabled. All three helpers just collect changesCountChanged, save started and save failed. They hold no save rules.

tsx
import { Grid, useGridApi, useGridChanges } from '@maxgrid/react';

export function SaveBar({ options }: { options: GridOptions<Employee> }) {
  const [api, gridRef] = useGridApi<Employee>();
  const { count, added, modified, removed, saving } = useGridChanges(api);

  return (
    <>
      <button disabled={!count || saving} onClick={() => api?.save(postBulk)}>
        {saving ? 'Saving…' : `Save (${added} added · ${modified} modified · ${removed} removed)`}
      </button>
      <Grid ref={gridRef} options={options} />
    </>
  );
}

While api is null, useGridChanges(api) returns no changes. The hook has no failure message. Read the result save() returns, or listen with onSaveFailed.

Server rendering ​

On the server, all three wrappers create no grid and emit only an empty container. The grid appears after mount on the client, so the server HTML and the client HTML have the same structure and hydration does not mismatch. Importing the packages does not touch window or document.

With the Next.js App Router, 'use client' is required. The package bundle already starts with that directive, so importing Grid from a server component raises no error. But options.columns can hold functions such as reactCell, so the file that builds options must be a client component.

tsx
'use client';

import { Grid } from '@maxgrid/react';
// Put the directive at the top of the file that builds options and renders <Grid />.

Effects do not run on the server, so only an empty <div> goes out. To avoid the React 18 server warning for useLayoutEffect, the server path uses useEffect.

The HTML from the server has no grid, so the area is blank until JavaScript loads. Set the container's height in CSS, and the page does not jump when the grid appears.

What was verified (2026-11-26)

We built and ran a Next.js 16.4.6 (App Router) app and a Nuxt 4.7.0 app with the 1.7.0 packages and checked them in Chromium. Details are in the React and Vue guides. Angular Universal was not run; it is covered by wrapper unit tests only.

Pitfalls ​

  • If you write options= and build a new object on every render, setOptions runs each time the parent renders. Core compares properties and applies only the changes, so the screen is right, but the work is wasted. Keep the columns array outside the component or in useMemo.
  • Component cells cannot go through columns passed straight to core, as in ref.setColumns(...) (Cells from components). To change columns, pass a changed options.
  • Before the grid exists, GridApi is null. For work that must happen once right after mount, use onReady in React, @ready in Vue, and add 'ready' to [events] in Angular.
  • Under React StrictMode's double mount, only one grid remains. Seeing a creation log twice in development is normal.
  • Angular inputs are declared with the @Input decorator. The minimum supported version (Angular 17.0) has no input() function. How you use them in a template does not change.