Smart Grid Modularity Guide

Data Grid Modularity

Smart.Grid supports both bundle-first and module-first integration. This guide shows how to build a reliable modular setup with Grid and registerModules, starting from beginner defaults and scaling to advanced production patterns.

License requirement: the modular Grid setup documented in this topic (including Grid + registerModules) is available only in the licensed version.

Who This Guide Is For

  • Entry developers: copy the quick-start imports and baseline config, then enable features one by one.
  • Advanced developers: control bundle size, load modules intentionally, and apply feature-specific optimizations.
  • Teams: use the module map and troubleshooting checklist to standardize setups across applications.

Bundle vs Modular Imports

Approach JavaScript Use Case
Full bundle smart.grid.js Fast setup, everything included
Modular smart.grid.core.js + selected feature modules Smaller build, feature-by-feature control
Important: in modular mode, importing a module file is not enough by itself. You must also register that module through registerModules([...]).

Quick Start (Recommended Baseline)

Use this as your default starting point for modular Grid in demos and new projects. It includes the common interactive features: filtering, sorting, editing, selection, resize, reorder, and menu.

import { Grid, registerModules } from '../../../source/modules/smart.grid.core.js';
import { FilterModule } from '../../../source/modules/smart.grid.filter.js';
import { SortModule } from '../../../source/modules/smart.grid.sort.js';
import { EditModule } from '../../../source/modules/smart.grid.edit.js';
import { ResizeModule } from '../../../source/modules/smart.grid.resize.js';
import { ReorderModule } from '../../../source/modules/smart.grid.reorder.js';
import { SelectModule } from '../../../source/modules/smart.grid.select.js';
import { MenuModule } from '../../../source/modules/smart.grid.menu.js';

registerModules([FilterModule, SortModule, EditModule, ReorderModule, ResizeModule, SelectModule, MenuModule]);

Feature to Module Map

Grid FeatureJS ModuleTypical Config FlagRecommended CSS
Core rendering and data bindingsmart.grid.core.jsN/A (always required)smart.grid.core.css
Sortingsmart.grid.sort.jssortable: truesmart.grid.sort.css
Filteringsmart.grid.filter.jsfilterable: truesmart.grid.filter.css
Selectionsmart.grid.select.jsselectable: truesmart.grid.select.css
Editingsmart.grid.edit.jseditable: truesmart.grid.edit.css
Resizesmart.grid.resize.jscolumn resize optionssmart.grid.core.css
Reordersmart.grid.reorder.jsrow/column reorder optionssmart.grid.core.css
Menusmart.grid.menu.jsmenu-related optionssmart.grid.core.css
Pagingsmart.grid.pager.jspaging: truesmart.grid.pager.css
Groupingsmart.grid.group.jsgroup optionssmart.grid.group.css
Tree datasmart.grid.tree.jstree/grid tree optionssmart.grid.tree.css
Exportsmart.grid.export.jsexport APIssmart.grid.core.css

Complete JavaScript Grid Modules

Source: source/modules/

ModulePurpose
smart.grid.jsFull Grid bundle (all core functionality together)
smart.grid.core.jsBase Grid engine (required for modular builds)
smart.grid.celltemplate.jsCell template support
smart.grid.chart.jsChart-related integration support
smart.grid.dropdown.jsDropdown interactions used by Grid UI
smart.grid.edit.jsEditing workflows
smart.grid.editors.jsEditor components used during cell/row edit
smart.grid.export.jsData export capabilities
smart.grid.filter.jsFiltering engine and UI
smart.grid.group.jsGrouping support
smart.grid.menu.jsContext/column menu support
smart.grid.pager.jsPaging and pager UI
smart.grid.reorder.jsReordering (rows/columns where applicable)
smart.grid.resize.jsResize support
smart.grid.select.jsSelection engine
smart.grid.sort.jsSorting engine
smart.grid.state.jsState persistence/restore helpers
smart.grid.tree.jsTree/hierarchical Grid behaviors
smart.grid.view.jsView/rendering-level helpers
smart.gridpanel.jsGrid panel companion module
Load order rule: always load smart.grid.core.js before feature modules in a modular setup.

Grid Modular Example (Update Data)

The demos/grid/datagrid-update-data sample demonstrates the same modular approach for Data Grid: start from smart.grid.core.js, register only the modules you need, then create a Grid instance. This keeps production bundles smaller while preserving feature parity.

JavaScript modules used in the demo

import { Grid, registerModules } from '../../../source/modules/smart.grid.core.js';
import { FilterModule } from '../../../source/modules/smart.grid.filter.js';
import { SortModule } from '../../../source/modules/smart.grid.sort.js';
import { EditModule } from '../../../source/modules/smart.grid.edit.js';
import { ResizeModule } from '../../../source/modules/smart.grid.resize.js';
import { ReorderModule } from '../../../source/modules/smart.grid.reorder.js';
import { SelectModule } from '../../../source/modules/smart.grid.select.js';
import { MenuModule } from '../../../source/modules/smart.grid.menu.js';

registerModules([FilterModule, SortModule, EditModule, ReorderModule, ResizeModule, SelectModule, MenuModule]);

Instance setup used in the demo

// HTML host:
// <smart-grid id="grid"></smart-grid>
const grid = new Grid(document.querySelector('#grid'), {
  dataSource: [
    { id: 0, firstName: 'John', lastName: 'Doe', productName: 'Black Tea', quantity: 15, price: 2.5, total: 37.5, date: new Date(2026, 0, 1) },
    { id: 1, firstName: 'Jane', lastName: 'Smith', productName: 'Green Tea', quantity: 10, price: 1.5, total: 15, date: new Date(2026, 0, 2) }
  ],
  dataSourceSettings: {
    dataFields: [
      'id: number',
      'firstName: string',
      'lastName: string',
      'productName: string',
      'date: date',
      'quantity: number',
      'price: number',
      'total: number'
    ]
  },
  editable: true,
  sortable: true,
  filterable: true,
  selectable: true,
  columns: [
    { label: 'First Name', dataField: 'firstName', columnGroup: 'name' },
    { label: 'Last Name', dataField: 'lastName', columnGroup: 'name' },
    { label: 'Product', dataField: 'productName', columnGroup: 'order' },
    { label: 'Quantity', dataField: 'quantity', columnGroup: 'order' },
    { label: 'Unit Price', dataField: 'price', cellsFormat: 'c2', columnGroup: 'order' },
    { label: 'Date', dataField: 'date', cellsFormat: 'd', columnGroup: 'order' },
    { label: 'Total', dataField: 'total', cellsFormat: 'c2', columnGroup: 'order' }
  ]
});

CSS modules used in the demo

<link rel="stylesheet" href="../../../source/styles/modules/smart.grid.core.css" />
<link rel="stylesheet" href="../../../source/styles/modules/smart.grid.sort.css" />
<link rel="stylesheet" href="../../../source/styles/modules/smart.grid.filter.css" />
<link rel="stylesheet" href="../../../source/styles/modules/smart.grid.select.css" />
<link rel="stylesheet" href="../../../source/styles/modules/smart.grid.edit.css" />
Data Grid load rule: load smart.grid.core.js first, then feature modules. Align loaded JS and CSS modules for each enabled feature.
Host element rule: default host is <smart-grid id="grid"></smart-grid>. If you initialize from a div, set appendTo: '#grid' in grid options.

Live Demo (datagrid-module)

The live demo below loads the datagrid-module sample directly in an iframe. If your environment blocks embedded pages, open the same demo in a separate tab.

Open datagrid-module demo in a new tab

Complete CSS Grid Modules

Source: source/styles/modules/

CSS ModulePurpose
smart.grid.cssBundle-level Grid stylesheet
smart.grid.core.cssCore Grid styling baseline
smart.grid.edit.cssEditing visuals
smart.grid.filter.cssFiltering UI styles
smart.grid.group.cssGrouping UI styles
smart.grid.pager.cssPager styles
smart.grid.select.cssSelection visuals
smart.grid.sort.cssSort indicator styles
smart.grid.sticky.cssSticky rows/columns styles
smart.grid.tree.cssTree Grid styles
smart.gridlayout.cssGrid layout support styles
smart.gridpanel.cssGrid panel styles

How to Use Modular Grid (ES Modules)

The pattern is always the same: (1) import core and feature module exports, (2) call registerModules, (3) create new Grid(...) with matching feature flags and a valid host setup.

// HTML:
// <smart-grid id="grid"></smart-grid>
import { Grid, registerModules } from '../../../source/modules/smart.grid.core.js';
import { FilterModule } from '../../../source/modules/smart.grid.filter.js';
import { SortModule } from '../../../source/modules/smart.grid.sort.js';
import { EditModule } from '../../../source/modules/smart.grid.edit.js';
import { ResizeModule } from '../../../source/modules/smart.grid.resize.js';
import { ReorderModule } from '../../../source/modules/smart.grid.reorder.js';
import { SelectModule } from '../../../source/modules/smart.grid.select.js';
import { MenuModule } from '../../../source/modules/smart.grid.menu.js';

registerModules([FilterModule, SortModule, EditModule, ReorderModule, ResizeModule, SelectModule, MenuModule]);

const grid = new Grid(document.querySelector('#grid'), {
  dataSource: [
    { id: 0, firstName: 'John', lastName: 'Doe', productName: 'Black Tea', quantity: 15, price: 2.5, total: 37.5, date: new Date(2026, 0, 1) },
    { id: 1, firstName: 'Jane', lastName: 'Smith', productName: 'Green Tea', quantity: 10, price: 1.5, total: 15, date: new Date(2026, 0, 2) }
  ],
  dataSourceSettings: {
    dataFields: [
      'id: number',
      'firstName: string',
      'lastName: string',
      'productName: string',
      'date: date',
      'quantity: number',
      'price: number',
      'total: number'
    ]
  },
  editable: true,
  sortable: true,
  filterable: true,
  selectable: true,
  columns: [
    { label: 'First Name', dataField: 'firstName', columnGroup: 'name' },
    { label: 'Last Name', dataField: 'lastName', columnGroup: 'name' },
    { label: 'Product', dataField: 'productName', columnGroup: 'order' },
    { label: 'Quantity', dataField: 'quantity', columnGroup: 'order' },
    { label: 'Unit Price', dataField: 'price', cellsFormat: 'c2', columnGroup: 'order' },
    { label: 'Date', dataField: 'date', cellsFormat: 'd', columnGroup: 'order' },
    { label: 'Total', dataField: 'total', cellsFormat: 'c2', columnGroup: 'order' }
  ]
});

Alternative host: initialize from a div

// HTML:
// <div id="grid"></div>
const grid = new Grid(document.createElement('div'), {
  appendTo: '#grid',
  dataSource: [],
  columns: []
});

Advanced Patterns

1) Feature-set registration per page/app area

Register only what the current page needs. For example, an analytics screen may need sort/filter but not edit. This helps control initial load size and avoids hidden dependencies.

2) Lazy-load heavier modules

If a feature is rarely used (for example export), load and register it only when needed.

async function enableExportFeature() {
  const { ExportModule } = await import('smart-webcomponents/source/modules/smart.grid.export.js');
  registerModules([ExportModule]);
}

3) Keep config and module sets in sync

If sortable: true is enabled, include SortModule. If sorting is disabled in product requirements, remove both the flag and module. This practice reduces regressions and improves maintainability.

4) Recommended initialization order

  1. Import module exports.
  2. Register feature modules.
  3. Create host element (or select existing host).
  4. Create Grid instance with options.
  5. Apply data updates and event wiring.

5) State persistence strategy

For enterprise apps, pair the state module with application-level persistence (for example local storage or server profile settings) so users keep column, sort, and filter preferences across sessions.

Troubleshooting Checklist

SymptomLikely CauseFix
Grid renders but feature does not workFeature module not registeredImport module export and add it to registerModules([...])
Feature UI looks broken or incompleteMissing feature CSS moduleAdd corresponding CSS module file to the page/bundle
Runtime import errorWrong module pathVerify relative path and filename from source/modules
Unexpected behavior after refactorFlag/module mismatchAudit config flags (sortable, filterable, etc.) against registered modules
Works locally, fails in productionBundler removed required moduleConfirm import is reachable and not conditionally stripped by build tooling

Production Webpack Starter (Modular Grid)

Use module-level imports in your entry file so bundlers include only selected functionality and styles. For production apps, prefer extracted CSS and code splitting where appropriate.

1) Install

npm i smart-webcomponents
npm i -D webpack webpack-cli style-loader css-loader html-webpack-plugin mini-css-extract-plugin

2) Entry file (src/index.js)

import 'smart-webcomponents/source/styles/modules/smart.grid.core.css';
import 'smart-webcomponents/source/styles/modules/smart.grid.sort.css';
import 'smart-webcomponents/source/styles/modules/smart.grid.filter.css';
import 'smart-webcomponents/source/styles/modules/smart.grid.pager.css';

import { Grid, registerModules } from 'smart-webcomponents/source/modules/smart.grid.core.js';
import { SortModule } from 'smart-webcomponents/source/modules/smart.grid.sort.js';
import { FilterModule } from 'smart-webcomponents/source/modules/smart.grid.filter.js';
import { MenuModule } from 'smart-webcomponents/source/modules/smart.grid.menu.js';
import { SelectModule } from 'smart-webcomponents/source/modules/smart.grid.select.js';

registerModules([SortModule, FilterModule, MenuModule, SelectModule]);

const gridHost = document.querySelector('#grid'); // <smart-grid id="grid"></smart-grid>
new Grid(gridHost, {
  dataSource: [
    { firstName: 'Nancy', lastName: 'Davolio', product: 'Espresso' },
    { firstName: 'Andrew', lastName: 'Fuller', product: 'Latte' }
  ],
  sortable: true,
  filterable: true,
  selectable: true,
  columns: [
    { label: 'First Name', dataField: 'firstName' },
    { label: 'Last Name', dataField: 'lastName' },
    { label: 'Product', dataField: 'product' }
  ]
});

3) Webpack config (webpack.config.js)

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

module.exports = {
  mode: 'production',
  entry: './src/index.js',
  output: {
    filename: 'bundle.[contenthash].js',
    path: path.resolve(__dirname, 'dist'),
    clean: true
  },
  module: {
    rules: [
      {
        test: /\.css$/i,
        use: [MiniCssExtractPlugin.loader, 'css-loader']
      }
    ]
  },
  plugins: [
    new MiniCssExtractPlugin({ filename: 'styles.[contenthash].css' }),
    new HtmlWebpackPlugin({
      templateContent: `
        <!doctype html>
        <html lang="en">
        <head>
          <meta charset="utf-8" />
          <meta name="viewport" content="width=device-width, initial-scale=1" />
          <title>Data Grid Modular Build</title>
        </head>
        <body>
          <smart-grid id="grid"></smart-grid>
        </body>
        </html>
      `
    })
  ]
};

4) Build

npx webpack

Production Best Practices

  • Prototype with smart.grid.js, then migrate to modular imports before release.
  • Treat module registration as part of feature design, not as an afterthought.
  • Keep JavaScript modules, CSS modules, and grid flags intentionally synchronized.
  • Prefer one centralized registration utility per app to avoid duplicated module logic.
  • Load rare features lazily to keep initial bundles smaller.
  • Add regression tests for sorting/filtering/editing when changing module sets.
  • When debugging, check module registration first, then CSS coverage, then data/config.