Get startedGet started for free

Dash AG Grid interactivity

1. Dash AG Grid interactivity

Let's learn how to style and add interactivity to Dash AG Grid Tables.

2. Styling all AG Grid cells

When styling a Dash AG Grid table, we can't use the usual style property to control cell appearance. Instead, we use another argument in the default column definition configuration. We use the cell style parameter to apply consistent styling across all cells. This parameter accepts standard CSS properties, such as aligning text to the right.

3. Styling some AG Grid cells

We can also style individual columns by setting cell style within that column's definition. Here, our major category column is center-aligned, while total sales is right-aligned.

4. More styling examples

We can use other familiar CSS properties for styling. In this example, we set the cell background color to black and the text color to white. Note that this applies only to cells, not the column headers.

5. Selecting cells

To add interactivity, AG Grid allows users to click on any cell and trigger a callback. No special flag is needed - clicking a cell automatically fires the cell-clicked event. Here is a quick callback example. We use the cell clicked property as the input to a callback, and send the output to a text element below the table. The event data is displayed each time a cell is clicked. It includes the row index, column ID, and value - all of which we can use in our app logic.

6. Selecting rows

If we want users to select rows instead of individual cells, we can enable row selection. To do this, we set the row selection option to either single or multiple when configuring the grid. To demonstrate the result, we've set up a callback similar to the one for cell clicks - but this time, the input is based on selected rows. When a row is selected, we get its full data as output, ready to use in other components or logic.

7. Let's practice!

Let's practice styling and adding callback interactivity to Dash AG Grid tables.

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.