Referencing another field in cellRenderer

75 Views Asked by At

I am using AG-Grid. I have bunch of fields in columnDefs and a cellRenderer for one of the fields. I want to refer to another field in the cellRenderer. How can I do it?

Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

The cell renderer params property has the type ICellRendererParams, which you can read about in the AG-Grid docs. The cell renderer params get automatically passed as a prop params to the cell renderer component.

The ICellRendererParams property data contains the data for the entire row, which you can use to reference your required field:

const props = defineProps({
  params: {
    type: Object as PropType<ICellRendererParams>,
    required: true,
  },
});

// access the field with: props.params.data["theRequiredField"];