> For the complete documentation index, see [llms.txt](https://docs.gridmate.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gridmate.io/product-tour/grids/apex-data-grid.md).

# 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**.

{% stepper %}
{% step %}

### Create the provider class

Create an Apex class **AccountHealthDataGridProvider** that implements **gmpkg.IApexDataGridProvider**. Declare it **global**.
{% endstep %}

{% step %}

### 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.
{% endstep %}

{% step %}

### 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.
{% endstep %}

{% step %}

### Create an app page

From Setup, create an app page in the Lightning App Builder.
{% endstep %}

{% step %}

### 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.
{% endstep %}

{% step %}

### 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.
{% endstep %}
{% endstepper %}

## 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***                                                                                                                                                                                                                            |       |

{% hint style="info" %}
See [GM - Apex Data Grid](https://docs.gridmate.io/package-reference/components-library/grids/gm-apex-data-grid.md#building-a-provider) for the provider interface and the column builder.
{% endhint %}

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

{% embed url="<https://youtu.be/xdbhYZqvlw4>" %}
GM - Apex Data Grid
{% endembed %}

## Next steps

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Report Table</strong></td><td>Embed Salesforce reports as tables on any Lightning page.</td><td><a href="https://docs.gridmate.io/product-tour/grids/report-table.md">Report Table</a></td></tr><tr><td><strong>Grid - Mass/Record Actions</strong></td><td>Add toolbar, global and record actions to the grid.</td><td><a href="https://docs.gridmate.io/advanced-guides/grid-actions/actions-library.md">Grid - Mass/Record Actions</a></td></tr><tr><td><strong>GM - Apex Data Grid</strong></td><td>Every property of the component, the provider interface and the column builder.</td><td><a href="https://docs.gridmate.io/package-reference/components-library/grids/gm-apex-data-grid.md">GM - Apex Data Grid</a></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.gridmate.io/product-tour/grids/apex-data-grid.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
