Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

GM - Apex Data Grid

(gmpkg:ApexDataGridComponent)

Documentation

GM - Apex Data Grid component is used to display the rows returned by your own Apex class instead of records from a query: data from an external system or a callout, computed rows, or aggregates. GridMate renders them with the grid experience: search, sort, totals, grouping, cell coloring, frozen columns, fullscreen, actions and export.

Use case: Display an Account Health grid computed by an Apex class from the opportunities and cases of each account, see GM - Apex Data Grid.

The grid is read-only: there is no inline editing, record creation, deletion or mass update. Because the rows don't come from a query, your Apex class handles search, filter, sort and the row count itself. See Building a Provider.

Specification

Property
Type
Description

recordId

String

recordId to use. Keep this empty if you want to use the current record.

Provider Class*

String

The name of the Apex class that implements gmpkg.IApexDataGridProvider.

DataGrid Code

String

The code to identify the data grid.

Custom Label

String

Override the label of the data grid. Set it: the grid has no object label to fall back on.

Custom Icon

String

Customize the data grid icon. All Lightning icons are supported, for example standard:account.

Row Limit

Integer

The maximum number of rows to fetch. The default value is 5000.

Page Size

Integer

The number of rows to fetch per step. The default value is 10.

Enable Pagination

Boolean

Check this option to enable pagination instead of scrolling. The grid calls getItemsCount for the total.

Grid Height

Integer

Set the grid height.

Filter

String

JSON filter criteria, sent to your Apex class as filterBy. $recordId is replaced with the current record Id. Ex. {"Health":"At Risk"}

Search Fields

String

, separated search fields. The search terms reach your Apex class inside filterBy.

Wildcard Search

Boolean

Check this option to use wildcard search. The default value is checked.

Sort

String

The column to sort the data grid on the initial load. Ex. OpenPipeline

Order

String

Asc or Desc order for sorting.

Aggregate

String

JSON string to define the aggregate columns. The component supports sum, min and max. Ex. {"OpenPipeline":"sum"}

Group By

String

, separated list of columns to group by.

Collapse Groups

Boolean

Check this option to collapse groups by default.

Multi Level Grouping

Boolean

Check this option to enable multi level grouping.

Show Aggregate Header

Boolean

Check this option to show the aggregate header as a card on top of the grid. The default value is checked.

Enable Freeze Columns

Boolean

Check this option if you want to freeze columns. The default value is checked.

Frozen Columns

Integer

# of columns to freeze.

Enable Toggle Fullscreen

Boolean

Check this option if you want to enable toggle fullscreen.

Enable Interactive Filters

Boolean

Check this option if you want to enable interactive filters.

Hidden Columns

String

, separated list of hidden columns.

Column Style

String

JSON string to define column styles. Ex. {"Name":"width:240px"}

Custom Field Labels

String

{name:label} custom field labels map.

Cell Coloring

String

JSON conditions for cell coloring.

Show Border

Boolean

Check this option to show a border around the grid. The default value is checked.

Show Column Border

Boolean

Check this option to show column borders. The default value is checked.

Hide Row Numbers

Boolean

Check this option to hide row numbers.

Auto Select 1st Row

Boolean

Check this option to select the first row automatically.

Total Color

String

Total row text color. The default value is #FFFFFF.

Total Background

String

Total row background color. The default value is #0176D2.

Density

String

Grid density: comfy | compact.

Disable Refresh View

Boolean

Check this option to disable the view refresh after an update.

Actions

String

JSON string to initialize the list of available actions from the data grid. See Export.

Show Actions as Buttons

Boolean

Use buttons for actions instead of icons.

Custom Visible Actions

Integer

# of visible custom actions.

API Reference

Building a Provider

A provider is an Apex class that implements the GridMate interface gmpkg.IApexDataGridProvider:

  • getDataGridMetadata returns the grid name, its label and its columns. Build it with gmpkg.ApexDataGridBuilder.buildGridMetadata.

  • getItems returns the rows: one Map<String, Object> per row, keyed by column name.

  • getItemsCount returns the number of rows that match filterBy. It is used by pagination.

Columns

Build the columns with gmpkg.ApexDataGridBuilder:

Factory
Column type

text(name, label, length)

Text

longText(name, label, length)

Long text

richText(name, label, length)

Rich text

number(name, label, precision, scale)

Number

integer(name, label)

Integer

currency(name, label, precision, scale)

Currency

percent(name, label, precision, scale)

Percent

date(name, label) / dateTime(name, label) / time(name, label)

Date / Date-time / Time

checkbox(name, label)

Checkbox

picklist(name, label, options)

Picklist

multiPicklist(name, label, options)

Multi-select picklist

email(name, label) / phone(name, label) / url(name, label)

Email / Phone / URL

options is a List<Map<String, String>> of {'label' => …, 'value' => …}.

Chain these modifiers on a column:

Modifier
Effect

withSortable(true)

Users can sort on the column. Columns aren't sortable without it.

withHelp(text)

A help icon on the column header.

withRequired(Boolean)

Marks the column as required.

withLength(Integer) / withPrecision(p, s)

Changes the size of the column's values.

buildGridMetadata(name, label, columns) returns the metadata map. It also carries your org's DataGrid Settings: export permission, CSV separator, export date formats, auto-adjusted columns and row numbers.

Rows

  • Return each row as a Map<String, Object> keyed by the column names.

  • Always include an Id key. The grid uses it to tell rows apart.

  • When Id holds a record Id, a Name column links to that record.

Parameters

Parameter
Value

filterBy

A JSON string in the GridMate filter format. It starts as the Filter property, or {} when it's blank. A search adds {"or":[{"<Search Field>":{"operator":"strictLike","value":"%term%"}}, …]} inside an and.

sortBy

The column the user sorted on, or the Sort property.

orderBy

asc or desc.

rowLimit

The number of rows to return.

rowOffset

The offset of the current page.

Return rows from the first one, up to rowLimit. The grid keeps track of the page itself, so don't skip rowOffset rows.

Example

Export

The grid has no built-in export button. Add the gmpkg:ApexDataGridExportComponent in the Actions property, with your provider class:

The user picks Comma Delimited .csv, Excel File or Formatted Excel File and a file name. The export calls getItems once, from the first row, and contains every row your class returns (up to 50,000), in the visible columns.

Last updated

Was this helpful?