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

Apex Data Grid

Show rows returned by an Apex class in a grid with search, sort, totals and export.

GridMate provides a lightning grid component GM - Apex Data Grid to display data that doesn't come from a query: an external system, a callout, computed rows or aggregates. Your Apex class returns the rows, and GridMate gives them the full grid experience: search, sort, totals, grouping, cell coloring and export.

In this tutorial, we will create an Account Health grid using GM - Apex Data Grid. For every account, an Apex class totals the opportunities and the open cases, computes the win rate, and flags the account as Healthy, Watch or At Risk.

1

Create the provider class

Create an Apex class AccountHealthDataGridProvider that implements gmpkg.IApexDataGridProvider. Declare it global.

2

Define the columns

In getDataGridMetadata, define the columns with gmpkg.ApexDataGridBuilder: Account Name, Industry, Health, Open Pipeline, Open Opps, Won Amount, Win Rate, Open Cases and Next Close Date.

3

Return the rows

In getItems, return one row per account, with an Id key holding the account Id. Apply the search and the sort received as parameters.

4

Create an app page

From Setup, create an app page in the Lightning App Builder.

5

Add the component

From the components list, drag and drop the component GM - Apex Data Grid. The grid component is now ready for configuration in the Lightning App Builder.

6

Configure the properties

The property values can be configured to tailor the data grid to the needs of the end-user. To perform a quick configuration, populate the property values in the table below.

Properties

Property
Demo value
Notes

Provider Class

AccountHealthDataGridProvider

Custom Label

Account Health

Custom Icon

standard:account

Row Limit

100

Page Size

60

Grid Height

640

Search Fields

Name,Industry

Wildcard Search

Checked

Sort

OpenPipeline

Order

desc

Aggregate

{"OpenPipeline":"sum","WonAmount":"sum","OpenOpps":"sum","OpenCases":"sum"}

Group By

Health

Show Aggregate Header

Checked

Cell Coloring

{"Health":[{"color":"#B0FD9F","exp":{"Health":{"operator":"=","value":"Healthy"}}},{"color":"#FFD59E","exp":{"Health":{"operator":"=","value":"Watch"}}},{"color":"#F7A8A8","exp":{"Health":{"operator":"=","value":"At Risk"}}}]}

Actions

[{"name":"exportHealth","label":"Export","global":true,"component":"gmpkg:ApexDataGridExportComponent","attributes":{"providerClass":"AccountHealthDataGridProvider"}}]

Show Actions as Buttons

Checked

See GM - Apex Data Grid for the provider interface and the column builder.

Below is a step by step tutorial to configure the GM - Apex Data Grid component.

GM - Apex Data Grid

Next steps

Was this helpful?