ag-gridag-grid-angularcellrenderer

ag-grid set cellRendererParams to values from the row data


I want to send data to my cellRenderer component via the cellRendererParams object but I don't know how to access row data for this. Here's an example of what I want to do:

cellRendererParams: {
    label: currentRowData.myField + currentRowData.myOtherField
}

I don't want my cellRenderer component to have knowledge of the data structure of the grid since I may use it in other grids with different row data.


Solution

  • there are many ways:

    1)

    valueGetter: (params) => ({ property1: params.data.myField1 + params.data.myField2, property2: params.data.someOtherField }),
    
    valueFormatter: ({ property1: params.data.myField1 + params.data.myField2, property2: params.data.someOtherField }),