ag-gridag-grid-ng2

How do I specify the RowNode.id in ag-grid


I'm posting this here because this wasted a fair bit of my time today.

I was trying to set the RowNode.id from the data in the objects I set aggrid's rowData property to. meaning, I wanted to use a property on my data model to supply the built in id field of ag-grid's row model. They mention this in the documentation but they don't explain how to do itp.


Solution

  • The answer to this question is that you need to set the getRowNodeId property on the grid options object for the grid, like so:

    // where 'd' is an object in your model
    this.gridOptions.getRowNodeId = d => {
       return d.id; // return the property you want set as the id.
    }