Clue Mediator

How to get Grid API and Column API in AG Grid

📅July 10, 2022

In this article, we will show you how to get Grid API and Column API in AG Grid. If you wish to integrate the AG Grid, you might need to perform additional actions using the Grid API or Column API. So here, we'll walk you through the process of getting the Grid Options.

Checkout more articles on ReactJS

Package Version

ag-grid-react

^25.2.0

ag-grid-community

^25.2.1

Steps to get Grid API and Column API

  1. Add AG Grid in React Component
  2. Add an event callback
  3. Output

1. Add AG Grid in React Component

Let’s create a react application using the `create-react-app` and implement AG Grid in React. Check the following article for more information.

How to implement AG Grid in React

2. Add an event callback

Now, in order to obtain the grid options, we must add the `onGridReady()` event callback. Look at the following code.

// access API from event object
const onGridReady = e => {
    console.log(‘Event Object:’, e);
}

//…
//…

<aggridreact ongridready={onGridReady} register="" event="" listener="" ...="">
</aggridreact>

3. Output

In the console window, you will find the grid API and the column API event object that help you to perform grid operations.

Output - How to get Grid API and Column API in AG Grid - Clue Mediator

Output - How to get Grid API and Column API in AG Grid - Clue Mediator

That’s it for today.
Thank you for reading. Happy Coding..!! 🙂

Demo & Source Code

GitHub Repository StackBlitz Project