Plain JavaScript
You do not need a framework. The maxgrid package contains the grid engine, the renderer and the theme CSS, so one .html file is enough. You can install it from npm, and this site (https://cdn.maxmine.com/maxgrid/1.8.0) also serves the same files itself.
Every method and option is listed in the API reference: GridApi and GridOptions.
Use a script tag
No bundler is needed. One <script> tag creates the global MaxGrid and brings the CSS with it. The first createGrid call adds a single <style> at the start of <head>.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
</head>
<body>
<div id="grid" style="height: 300px"></div>
<script src="https://cdn.maxmine.com/maxgrid/1.8.0/maxgrid.min.js"></script>
<script>
const api = MaxGrid.createGrid(document.getElementById('grid'), {
columns: [
{ id: 'name', title: 'Name' },
{ id: 'department', title: 'Department' },
{ id: 'salary', title: 'Salary', kind: 'number' },
],
rows: [
{ id: 1, name: 'Liam Carter', department: 'Engineering', salary: 84000 },
{ id: 2, name: 'Emma Wilson', department: 'Design', salary: 78000 },
],
rowKey: 'id',
});
</script>
</body>
</html>In production, pin the version in the URL (for example maxgrid@1.2.3). A URL without a version can start serving a different version later.
Use ES modules
Modern browsers load the module directly with type="module". It does not create a global variable.
<script type="module">
import { createGrid } from 'https://cdn.maxmine.com/maxgrid/1.8.0/maxgrid.esm.js';
createGrid(document.getElementById('grid'), { columns, rows, rowKey: 'id' });
</script>With a bundler such as Vite or webpack, install the package and import it.
pnpm add maxgridimport { createGrid } from 'maxgrid';createGrid adds the CSS for you. To turn that off and load it yourself, use import 'maxgrid/maxgrid.css'; (see Turn off style injection).
The package ships type declarations, so TypeScript can use GridOptions<Row> and GridApi<Row> directly. Importing the package on a server-rendered page does not throw. createGrid needs the DOM, so call it only in the browser.
Pin the version and verify integrity
In production, use the URL with the version in it and let the browser check the file with integrity. crossorigin="anonymous" must come with it.
<script src="https://cdn.maxmine.com/maxgrid/1.8.0/maxgrid.min.js" integrity="sha384-SsqJYyomnDFE9Aq35InPj08+I3SOPlTRGi17p59mmcEp914M1gDnC6n4TVAU+A13" crossorigin="anonymous"></script>https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js always points to the newest file, so its content changes. You cannot add integrity to it. Use it for trials only. The ES module file has its own hash (sha384-1sqrhBIw9xNVmwOwhwysNTBmvzch2r94slY+qnLxg/1gDcTkU9MOCbt4WX4e8m73).
Turn off style injection
If a Content-Security-Policy blocks inline <style> elements, pick one of two options. Set it once, before you call createGrid.
// 1) inject with a nonce
MaxGrid.config({ nonce: document.querySelector('meta[name=csp-nonce]').content });
// 2) turn injection off and load maxgrid.css yourself
MaxGrid.config({ injectStyles: false });<link
rel="stylesheet"
href="https://cdn.maxmine.com/maxgrid/1.8.0/maxgrid.css"
integrity="sha384-0q/mXgqsK9jzPq0hZVTqw6HO9Ybsi1rJRyxlVL/zLVNJDBG+2QzJgr7nwgsDDonc"
crossorigin="anonymous"
/>The injected <style> has a data-mxg-styles attribute. Loading the script more than once, or creating several grids, still leaves one <style>. It sits at the start of <head>, so page CSS with the same specificity always wins over the grid CSS. Importing the module on a server does nothing.
Subscribe to events
Subscribe on the api that createGrid returns. on returns a function that removes the subscription.
const off = api.on('rowClicked', ({ row, rowKey }) => {
console.log(rowKey, row.name);
});
api.on('sortChanged', ({ sortModel }) => console.log(sortModel));
off();Events lists the event names and payloads. ready fires right after createGrid returns, so you can register api.on('ready', …) on the next line and still receive it.
Change options and data
Pass only what changed instead of rebuilding the whole options object. Rows have their own methods.
api.setOptions({ density: 'compact', showRowNumbers: true });
api.setRows(newRows);
api.addRows([{ id: 3, name: 'Noah Brooks', department: 'Sales', salary: 72000 }]);
api.updateRows([{ id: 1, name: 'Liam Carter', department: 'Engineering', salary: 90000 }]);
api.removeRows([2]);
api.setSortModel([{ columnId: 'salary', direction: 'desc' }]);Data and rows and Sorting and filtering cover the rules.
Dark mode
Set data-mxg-theme="dark" on the grid or an ancestor. Remove the attribute to return to light.
document.documentElement.setAttribute('data-mxg-theme', 'dark');
document.documentElement.removeAttribute('data-mxg-theme');Clean up
Call destroy() when you remove the grid from the page. It removes the DOM, event listeners, scheduled renders and the size observer. After that you can create a new grid in the same container.
api.destroy();
const next = MaxGrid.createGrid(container, options);If your page replaces fragments of HTML, switches tabs or closes modals, call it before you remove the container. Without it the event listeners and the size observer stay behind.
Several grids on one page
Every createGrid call creates an independent grid. Changing the rows or the sort of one does not affect the others. Keep one api per grid.
const orders = MaxGrid.createGrid(document.getElementById('orders'), ordersOptions);
const stock = MaxGrid.createGrid(document.getElementById('stock'), stockOptions);Version, release date and checking for a grid
MaxGrid.VERSION is the bundle version and MaxGrid.RELEASE_DATE is its release date (YYYY-MM-DD). The date is not read from the clock at build time; it is the value the release tool (release:set-version) wrote, so the same source gives the same bundle. MaxGrid.isGridElement(el) is true while a grid created on that element is alive. It is false after destroy(), for an element that never had one, and for values that are not elements.
if (!MaxGrid.isGridElement(box)) MaxGrid.createGrid(box, options);Common pitfalls
The grid is not visible. The grid fills its container's height. A container without a height collapses to 0. Give it a height, such as style="height: 300px".
You created a grid twice in one container. Calling createGrid again without destroy() stacks a second grid on the first. Call the previous api.destroy() before you create a new one.
MaxGrid is not defined. The <script src=".../maxgrid.min.js"> tag must come before the script that creates the grid. If you add defer or async, move your own code into a DOMContentLoaded handler.
There is no styling. You turned injection off with MaxGrid.config({ injectStyles: false }), or a CSP blocks <style>. Load maxgrid.css yourself, once per page.
The page already has a global named MaxGrid. The IIFE file overwrites it. Load the ES module instead and choose your own name.
You also use the React, Vue or Angular wrappers. Install those from the @maxgrid/* packages. Adding maxgrid to the same page bundles the engine twice.
Pick only the features you need
To make the download smaller, load the basic maxgrid.core.min.js (or maxgrid/core) and add features such as tree, editing and column operations through features. The bundles, script combinations and bundler usage are in Pick features.
License key
Without a key, features stay the same and only a watermark and a console warning appear. localhost needs no key. Set it with MaxGrid.config({ licenseKey }); details are in License key.
Files and size
| File | Used for | Compressed (gzip) |
|---|---|---|
maxgrid.min.js | <script> tag. All features, global MaxGrid, CSS included | about 148.0 KB |
maxgrid.esm.js | import, type="module". All features, CSS included | about 148.6 KB |
maxgrid.core.min.js | Basic features only (modular), CSS included | about 85.3 KB |
maxgrid.hierarchy.min.js | Tree, grouping and aggregation add-on for core | about 17.2 KB |
maxgrid.editing.min.js | Editing and change tracking add-on for core | about 28.5 KB |
maxgrid.columns.min.js | Column operations add-on for core | about 14.1 KB |
maxgrid.pagination.min.js | Paging and pager add-on for core | about 6.4 KB |
maxgrid.filter.min.js | Header filter row and filter popup add-on for core | about 24.1 KB |
maxgrid.renderers.min.js | Six built-in cell renderers add-on for core | about 2.5 KB |
maxgrid.css | Theme (light and dark). The same file that is inside the JS | about 10.6 KB |
Sizes by combination, and when the modular files are smaller, are in Pick features.
Sizes were measured on 2026-11-13 (JavaScript with the CSS included). Source maps (.js.map) are not published, and the development-only checks are stripped. The complete code for the same scenario as the other demos (adding rows, batch save, rollback, sort/selection/focus display, 100,000-row scrolling, dark mode, recreating after destroy) in a single .html file is in the JavaScript tab of The same screen in React, Vue and Angular.