Expand All

  Getting Started



  Row Models





Github stars make projects look great. Please help, donate a star, it's free.
Get informed on releases and other ag-Grid news only - never spam.
Follow on Twitter

Row Height

By default, the grid will display rows at 25px. You can change this for each row individually to give each row a different height.

You cannot use variable row height when doing virtual paging or viewport. This is because these row models need to work out the position of rows that are not loaded and hence need to assume the row height is fixed.

rowHeight Property

To change the row height for the whole grid, set the property rowHeight to a positive number. For example, to set the height to 50px, do the following:

gridOptions.rowHeight = 50;

Changing the property will set a new row height for all rows, including floating rows top and bottom.

getRowHeight Callback

To change the row height so that each row can have a different height, implement the getRowHeight() callback. For example, to set the height to 50px for all non-floating rows and 25px for floating rows, do the following:

gridOptions.getRowHeight = function(params) {
    if (params.node.floating) {
        return 25;
    } else {
        return 50;

The params object passed to the callback has the following values:

Row Height Simple Example

The example below hows dynamic row height, specifying a different row height for each row. It uses the getRowHeight() callback to achieve this.

Row Height More Complex Example

Below shows a more complex example, where the row height is changed based on contents of the 'Latin Text' column. The column definition has CSS style so that the cell does not have it's contents clipped. The algorithm used to work out how tall the row should be is far from perfect, however it demonstrates that you can change your row height based on the contents of the cell.

Changing Row Height

Setting the row height is done once for each row. Once set, the grid will not ask you for the row height again. You can change the row height after it is initially set using a combination of api.resetRowHeights(), rowNode.setRowHeight() and api.onRowHeightChanged().


Call this API to have the grid clear all the row heights and work them all out again from scratch - if you provide a getRowHeight() callback, it will be called again for each row. The grid will then resize and reposition all rows again. This is the shotgun approach.

rowNode.setRowHeight(height) and api.onRowHeightChanged()

You can call rowNode.setRowHeight(height) directly on the rowNode to set it's height. The grid will resize the row but will NOT reposition the rows (ie if you make a row shorter, a space will appear between it and the next row, the next rows will not be moved up). When you have set the row height (potentially on many rows) you need to call api.onRowHeightChanged() to tell the grid to reposition the rows. It is intended that you can call rowNode.setRowHeight(height) many times and then call api.onRowHeightChanged() once at the end.

When calling rowNode.setRowHeight(height), you can either pass in a new height or null or undefined. If you pass a height, that height will be used for the row. If you pass in null or undefined, the grid will then calculate the row height in the usual way, either use the provided rowHeight property or getRowHeight() callback.

Example Changing Row Height

The example below changes the row height in the different ways described above.

  • Top Level Groups: The row height for the groups is changed by calling api.resetRowHeights(). This gets the grid to call api.getRowHeight() again for each row.
  • Swimming Leaf Rows: Same technique is used here as above above. You will need to expand a group with swimming (eg America) and the grid works out all row heights again.
  • Zimbabwe Leaf Rows: The row height is set directly on the rowNode. Then the grid is told to reposition all rows again via calling api.onRowHeightChanged().

Note that this example uses ag-Grid Enterprise as it uses grouping. Setting the row height is an ag-Grid free feature, we just demonstrate it against groups and normal rows below.

Height for Floating Rows

Row height for floating rows works exactly as per normal rows with one difference - it is not possible to dynamically change the height once set. However this is easily got around by just setting the floating row data again which resets the row heights. Setting the data again is not a problem for floating rows as it doesn't impact scroll position, filtering, sorting or group open / closed positions as it would with normal rows if the data was reset.