3

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.

HisDivineShadow
  • 1,036
  • 1
  • 12
  • 21

2 Answers2

1

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 }),
0

Try using a valueGetter, like this:

valueGetter: (params) => params.data.myField + params.data.myOtherField
rateLess
  • 667
  • 5
  • 4
  • I guess my example was a little simplistic in that it only shows one item in the cellRendererParams object. Your suggestion only works for the `value` property of the params object that's passed to the cellRenderer component. If there are multiple items that I want passed, e.g. `{ label: 'something', someBoolean: data.myBooleanField , someValue: dataRow.oneValue * dataRow.otherValue }`, then your solution doesn't work although, I do appreciate your solution as it does accomplish the simple case. – HisDivineShadow Dec 01 '20 at 22:24
  • So, I took your solution one step further and I was able to make it work. Instead of the `valueGetter` only returning one value I made it return an object, e.g. `valueGetter: (params) => ({ property1: params.data.myField1 + params.data.myField2, property2: params.data.someOtherField })`. If you update your answer to this, I will mark it as the accepted answer. – HisDivineShadow Dec 01 '20 at 22:59