apex-grid
    Preparing search index...

    Class ApexGrid<T>

    Apex grid is a web component for displaying data in a tabular format quick and easy.

    Out of the box it provides row virtualization, sort and filter operations (client and server side), the ability to template cells and headers and column hiding.

    A working, styled grid requires three things:

    1. Register the element: import 'apex-grid/define' (or ApexGrid.register()).
    2. Give the host element a bounded height, e.g. apex-grid { height: 480px } — the virtualizer collapses without one.
    3. Do NOT set display on the host — the component declares :host { display: grid } internally and any override breaks the track layout.

    The grid is styled out of the box through --ag-* CSS custom properties — there is no theme to import and no configureTheme() call. Override --ag-* tokens on the host (or any ancestor) to rebrand; when igniteui-webcomponents is present, the brand tokens auto-tint from its palette. For dark mode, set the theme="dark" attribute on the host for the built-in slate dark palette (further --ag-* overrides still compose on top). Add tinted (e.g. theme="tinted" or theme="dark tinted") to mix the brand into the chrome so the grid wears its brand even at rest. See the README "Getting Started" and "Theming" sections for the full example and token list.

    apex-grid

    theme - Space-separated theme flags. dark opts into the built-in dark palette; tinted mixes --ag-brand into the chrome surfaces. Combine as theme="dark tinted".

    sorting - Emitted when sorting is initiated through the UI.

    sorted - Emitted when a sort operation initiated through the UI has completed.

    filtering - Emitted when filtering is initiated through the UI.

    filtered - Emitted when a filter operation initiated through the UI has completed.

    pageChanging - Cancellable. Emitted before page/page-size changes are applied.

    pageChanged - Emitted after a page/page-size change has been applied.

    quickFilterChanging - Cancellable. Emitted before a quick-filter value is applied.

    quickFilterChanged - Emitted after a quick-filter change has been applied.

    columnPinning - Cancellable. Emitted before a column's pin position changes.

    columnPinned - Emitted after a column's pin position has changed.

    columnMoving - Cancellable. Emitted before a column is moved.

    columnMoved - Emitted after a column has been moved.

    cellValueChanging - Cancellable. Emitted before a cell value is committed.

    cellValueChanged - Emitted after a cell value has been committed.

    rowEditStarted - Emitted when a row enters edit mode (row mode only).

    rowEditEnded - Emitted when a row leaves edit mode (row mode only).

    rowSelecting - Cancellable. Emitted before a selection-set change is applied.

    rowSelected - Emitted after a selection-set change has been applied.

    rowExpanding - Cancellable. Emitted before the row-expansion set changes (master-detail).

    rowExpanded - Emitted after a row-expansion change has been applied.

    treeRowExpanding - Cancellable. Emitted before a tree-row expansion change (tree mode).

    treeRowExpanded - Emitted after a tree-row expansion change has been applied.

    live-region - Visually-hidden ARIA live region used for screen-reader announcements.

    [--ag-brand] - Brand color for selection, focus rings, and accents. Auto-tints from --ig-primary-500 when igniteui is present.

    [--ag-brand-strong] - Brand color for hover / pressed states.

    [--ag-grid-shadow] - Grid edge/shadow override. Default is a flat 1px hairline edge; set to var(--ag-shadow-card) for the elevated card look, or none to remove it.

    [--ag-grid-bg] - Host card background. Defaults to a subtle light gradient; override with a flat color (or use theme="dark") for dark themes.

    [--ag-surface] - Grid card background (must be opaque).

    [--ag-surface-alt] - Alternating row tint.

    [--ag-surface-elevated] - Header background.

    [--ag-hairline] - Header / structural gridline color.

    [--ag-border] - Row separator color.

    [--ag-text] - Primary text color.

    [--ag-text-body] - Row text color.

    [--ag-text-muted] - Muted text (roles, labels).

    [--ag-row-hover] - Row hover wash.

    [--ag-row-h] - Row height.

    [--ag-header-h] - Header height.

    [--ag-radius] - Outer card corner radius.

    [--ag-font] - Grid font family.

    [--ag-fs-cell] - Cell font size.

    _tokens.scss for the complete --ag-* token list.

    Type Parameters

    • T extends object

    Hierarchy

    Index

    Other

    autoGenerate: boolean = false

    Whether the grid will try to "resolve" its column configuration based on the passed data source.

    This is usually executed on initial rendering in the DOM. It depends on having an existing data source to infer the column configuration for the grid. Passing an empty data source or having a late bound data source (such as a HTTP request) will usually result in empty column configuration for the grid.

    This property is ignored if any existing column configuration already exists in the grid.

    In a scenario where you want to bind a new data source and still keep the auto-generation behavior, make sure to reset the column collection of the grid before passing in the new data source.

    // assuming autoGenerate is set to true
    grid.columns = [];
    grid.data = [...];

    auto-generate

    columnReordering: boolean = false

    Enables drag-and-drop column reordering on the column headers.

    Per-column opt-out is available through BaseColumnConfiguration.reorderable. Reordering is constrained to a column's own pinning group — start-pinned columns can only swap with start-pinned, unpinned with unpinned, and end-pinned with end-pinned.

    column-reordering

    columns: ColumnConfiguration<T, keyof T>[] = []

    Column configuration for the grid.

    data: T[] = []

    The data source for the grid.

    dataPipelineConfiguration: DataPipelineConfiguration<T>

    Configuration object which controls remote data operations for the grid.

    Inline editing configuration for the grid.

    Editing is disabled by default. Set enabled: true and (optionally) mode ('cell' | 'row') and trigger ('click' | 'doubleClick') to opt in. Per-column opt-in is required via BaseColumnConfiguration.editable.

    grid.editing = { enabled: true, mode: 'cell', trigger: 'doubleClick' };
    

    Row-expansion (master-detail) configuration for the grid.

    Expansion is disabled by default. Set enabled: true and supply a detailTemplate to opt in. The default UX renders a chevron toggle in a dedicated leading column; set showToggleColumn: false to drive expansion entirely through the public API or a custom cell template.

    grid.expansion = {
    enabled: true,
    detailTemplate: ({ data }) => html`<order-summary .order=${data}></order-summary>`,
    };

    Pagination configuration for the grid.

    Pagination is disabled by default. Set enabled: true and (optionally) pageSize to render the built-in <apex-grid-paginator> and slice the dataView. For server-side pagination set mode: 'remote' and supply totalItems. The grid emits the cancellable pageChanging event before applying a change and the pageChanged event after the pipeline has run.

    grid.pagination = { enabled: true, pageSize: 25 };
    grid.addEventListener('pageChanged', (event) => {
    console.log('Now on page', event.detail.page, 'of', event.detail.pageCount);
    });
    quickFilter: string = ''

    The quick-filter (global search) value applied to the dataView.

    When non-empty, the grid filters records whose visible-column values contain the term (case-insensitive substring match). Customise by providing DataPipelineConfiguration.quickFilter.

    quick-filter

    Row selection configuration for the grid.

    Selection is disabled by default. Set enabled: true and (optionally) mode ('single' | 'multiple') and showCheckboxColumn to opt in.

    grid.selection = { enabled: true, mode: 'multiple', showCheckboxColumn: true };
    
    showExport: boolean = false

    Whether the built-in export menu is rendered in the toolbar.

    When true, the toolbar shows a download button on the trailing side; clicking it opens a menu with one entry per ApexGrid.exportFormats (CSV in the community grid) that calls ApexGrid.exportAs. ApexGrid.exportToCSV remains callable programmatically regardless of this flag.

    show-export

    showQuickFilter: boolean = false

    Whether the built-in quick-filter input is rendered in the toolbar.

    The ApexGrid.quickFilter value can be controlled programmatically regardless of this flag; this only controls the toolbar input UI.

    show-quick-filter

    sortConfiguration: GridSortConfiguration = ...

    Sort configuration property for the grid.

    Tree-data (nested rows) configuration for the grid.

    Tree mode keeps ApexGrid.data flat; the grid derives the hierarchy from a user-supplied getDataPath(row) callback (AG Grid's "tree data" pattern). When enabled, the first visible data column (or the column referenced by groupColumnKey) renders a chevron toggle and depth-based indentation.

    grid.tree = {
    enabled: true,
    getDataPath: (row) => row.path, // e.g., ['Adrian'], ['Adrian', 'Bryan']
    defaultExpanded: true,
    };
    • get dataView(): readonly T[]

      Returns the state of the data source after sort/filter operations have been applied.

      Returns readonly T[]

    • get displayColumns(): readonly ColumnConfiguration<T>[]

      The columns in visual render order: 'start'-pinned columns first, then unpinned columns, then 'end'-pinned columns.

      Returns readonly ColumnConfiguration<T>[]

      Use this when you need to iterate the columns in the same order the grid actually displays them (for example to build a column chooser). Public APIs like ApexGrid.getColumn continue to operate on the user-supplied ApexGrid.columns array.

    • get editingCell(): { columnKey: keyof T; rowIndex: number } | null

      The cell currently in edit mode, or null.

      Returns { columnKey: keyof T; rowIndex: number } | null

    • get editingRow(): number | null

      The view-relative index of the row currently in edit mode (row edit mode only), or null.

      Returns number | null

    • get expandedRows(): T[]

      The currently expanded rows, in insertion order.

      Returns T[]

      Returned as a plain array snapshot — mutating the returned array does not change the grid's expansion state. Set this property to replace the expansion set programmatically (goes through the cancellable rowExpanding event).

    • get exportFormats(): readonly ExportFormat[]

      The export formats offered in the toolbar's export menu, in order.

      Returns readonly ExportFormat[]

      The community grid offers CSV only. This is the seam derived grids use to contribute more formats: @apexcharts/grid-enterprise overrides it to add 'xlsx'. The toolbar renders one menu item per entry and dispatches the chosen id to ApexGrid.exportAs.

    • get page(): number

      The current zero-based page index.

      Returns number

    • get pageItems(): readonly T[]

      The records currently rendered into the virtualized body.

      Returns readonly T[]

      Equal to ApexGrid.dataView when pagination is disabled. With pagination enabled ('local' mode) this is the active page slice.

    • get pageSize(): number

      The current page size.

      Returns number

    • get rows(): ApexGridRow<T>[]

      Returns the collection of rendered row elements in the grid.

      Returns ApexGridRow<T>[]

      Since the grid has virtualization, this property returns only the currently rendered chunk of elements in the DOM.

    • get selectedRows(): T[]

      The currently selected rows, in insertion order.

      Returns T[]

      Returned as a plain array snapshot — mutating the returned array does not change the grid's selection. Set this property to replace the selection programmatically (goes through the cancellable rowSelecting event).

    • get totalItems(): number

      The total number of items in the ApexGrid.dataView collection.

      Returns number

      This is always the post-filter, post-sort row count — pagination does not change it. Use ApexGrid.pageItems to read the rows currently rendered into the body.

    • Sets the live region's announcement text. Screen readers configured to read polite live updates will read the new value aloud.

      Parameters

      • message: string

      Returns void

      Use this from custom UI affordances (e.g. an "Apply filter" button) so the change is announced. Built-in operations (sort / filter / page / select / expand) call this internally already.

    • Discards the current edit without writing back to ApexGrid.data.

      Returns void

    • Resets the current filter state of the control.

      Parameters

      • Optionalkey: keyof T

      Returns void

    • Clears the row selection.

      Returns Promise<boolean>

    • Resets the current sort state of the control.

      Parameters

      • Optionalkey: keyof T

      Returns void

    • Collapses every currently expanded row.

      Returns Promise<boolean>

    • Collapses every currently-expanded tree row.

      Returns Promise<boolean>

    • Collapses row. No-op when the row is not currently expanded.

      Parameters

      • row: T

      Returns Promise<boolean>

    • Collapses a tree row. No-op when the row is not currently expanded.

      Parameters

      • row: T

      Returns Promise<boolean>

    • Commits the current edit.

      Returns Promise<boolean>

      In cell mode this writes the active cell's pending value. In row mode it flushes all pending values for the active row. Emits cellValueChanging per changed cell (cancellable) and cellValueChanged after, followed by rowEditEnded in row mode.

    • Deselects row. No-op if row is not currently selected.

      Parameters

      • row: T

      Returns Promise<boolean>

    • Begins editing the cell at (rowIndex, columnKey).

      Parameters

      • rowIndex: number
      • columnKey: keyof T

      Returns Promise<boolean>

      rowIndex is the view-relative index (matches ApexGrid.pageItems). Returns false when the column isn't editable, the row index is out of range, or the request was rejected (for example in row mode with pending changes that couldn't be committed).

    • Begins editing the entire row at rowIndex (row edit mode only).

      Parameters

      • rowIndex: number

      Returns Promise<boolean>

      false when editing is disabled, the grid is in cell mode, or the row index is out of range.

    • Expands every row in ApexGrid.dataView that passes the optional isExpandable predicate.

      Returns Promise<boolean>

    • Expands every parent row in the current tree.

      Returns Promise<boolean>

    • Expands row. No-op when the row is already expanded, expansion is disabled, or the optional isExpandable predicate rejects it.

      Parameters

      • row: T

      Returns Promise<boolean>

    • Expands a tree row. No-op when the row is already expanded, has no children, or tree mode is disabled.

      Parameters

      • row: T

      Returns Promise<boolean>

    • Exports the grid in the given format (one of ApexGrid.exportFormats). Called by the toolbar's export menu. The community grid handles 'csv'; derived grids override to handle additional formats, delegating to super for the ones they don't add.

      Parameters

      Returns void

    • Exports the current grid contents as a CSV string and (in a browser context) triggers a download.

      Parameters

      Returns string

      By default the export uses the post-filter/post-sort dataView, includes every visible column with exportable !== false, and prepends a UTF-8 BOM so Excel opens the file with the right encoding. Pass source: 'page' to export only the current page, source: 'selected' to export the current row selection, or source: 'all' to export the raw data array. The returned string is the same content written to the file — useful for tests or routing the bytes elsewhere.

      grid.exportToCSV();                                  // download data.csv
      grid.exportToCSV({ filename: 'users', source: 'selected' });
      const text = grid.exportToCSV({ filename: '' }); // string only, no download
    • Navigates to the first page.

      Returns Promise<boolean>

    • Navigates the grid to the given zero-based page index.

      Parameters

      • page: number

        The target zero-based page index.

      Returns Promise<boolean>

      true if the change was applied, false if cancelled or a no-op.

      Emits the cancellable pageChanging event before applying the change and the pageChanged event after. Out-of-range values are clamped into [0, pageCount - 1].

      await grid.gotoPage(2);
      
    • Whether row is currently expanded.

      Parameters

      • row: T

      Returns boolean

    • Whether row is currently selected.

      Parameters

      • row: T

      Returns boolean

    • Whether row is currently expanded in the tree.

      Parameters

      • row: T

      Returns boolean

    • Navigates to the last page.

      Returns Promise<boolean>

    • Moves a column relative to another column.

      Parameters

      • fromKey: keyof T

        The column to move.

      • toKey: keyof T

        The reference column.

      • position: ColumnDropPosition = 'before'

        Whether to place fromKey before or after toKey. Defaults to 'before'.

      Returns Promise<boolean>

      true if the move was applied, false if cancelled or a no-op.

      Emits the cancellable columnMoving event first and columnMoved after. Reordering only succeeds when the source and target columns share the same pinning group (start / unpinned / end) — cross-group moves return false. Use ApexGrid.pinColumn to change a column's pinning group first.

      await grid.moveColumn('email', 'name', 'after');
      
    • Navigates to the next page. No-op if already on the last page.

      Returns Promise<boolean>

    • Pins a column to one of the grid's edges, or unpins it when position is null.

      Parameters

      • key: keyof T

        The target column key.

      • position: PinPosition

        'start', 'end', or null to unpin.

      Returns Promise<boolean>

      true if the change was applied, false if cancelled or a no-op.

      Emits the cancellable columnPinning event first and the columnPinned event after the update is applied. The user-supplied ApexGrid.columns array is not reordered — only the visual render order changes.

      await grid.pinColumn('name', 'start');
      await grid.pinColumn('actions', 'end');
    • Navigates to the previous page. No-op if already on the first page.

      Returns Promise<boolean>

    • Selects every row in the current view (dataView). No-op in 'single' selection mode.

      Returns Promise<boolean>

    • Selects row, replacing the existing selection in 'single' mode or adding to it in 'multiple' mode.

      Parameters

      • row: T

      Returns Promise<boolean>

      true if the selection changed, false if the change was rejected by a rowSelecting listener or selection is disabled.

    • Updates the grid's page size and returns to the first page.

      Parameters

      • size: number

        The new page size (must be a positive integer).

      Returns Promise<boolean>

      true if the change was applied, false if cancelled or a no-op.

      Emits the cancellable pageChanging event before applying the change and the pageChanged event after.

    • Applies a new quick-filter (global search) value, emitting the cancellable quickFilterChanging event first and the quickFilterChanged event after the pipeline has run.

      Parameters

      • value: string

        The new quick-filter value. Pass '' to clear.

      Returns Promise<boolean>

      true if the change was applied, false if cancelled or a no-op.

      await grid.setQuickFilter('john');
      
    • Toggles expansion of row.

      Parameters

      • row: T

      Returns Promise<boolean>

    • Toggles selection of row.

      Parameters

      • row: T

      Returns Promise<boolean>

    • Toggles tree-expansion of row. No-op when tree mode is disabled or the row has no children.

      Parameters

      • row: T

      Returns Promise<boolean>

    • Unpins a column. Equivalent to ApexGrid.pinColumn(key, null).

      Parameters

      • key: keyof T

        The target column key.

      Returns Promise<boolean>

      true if the change was applied, false if the column was already unpinned or the operation was cancelled.

    • Updates the column configuration of the grid.

      Parameters

      Returns void

      Each updated column is replaced with a fresh object reference so that cells and headers re-render with the new template / configuration. The user-supplied columns array is also reassigned for Lit reactivity.

    • Registers <apex-grid> and its internal dependencies with the custom-element registry. Idempotent — safe to call more than once.

      Returns void

      Registering the element is only step one of four required for a visible, styled grid. You must also configure an Ignite UI theme + CSS, give the host a bounded height, and avoid overriding display on the host. See the README "Getting Started" section for the full setup.

    styles

    styles: CSSResult = gridStyles

    Array of styles to apply to the element. The styles should be defined using the css tag function, via constructible stylesheets, or imported from native CSS module scripts.

    Note on Content Security Policy:

    Element styles are implemented with <style> tags when the browser doesn't support adopted StyleSheets. To use such <style> tags with the style-src CSP directive, the style-src value must either include 'unsafe-inline' or nonce-<base64-value> with <base64-value> replaced be a server-generated nonce.

    To provide a nonce to use on generated <style> elements, set window.litNonce to a server-generated nonce in your page's HTML, before loading application code:

    <script>
    // Generated and unique per request:
    window.litNonce = 'a1b2c3d4';
    </script>