Search code examples
ag-gridag-grid-vue

Referencing another field in cellRenderer


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


Solution

  • 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"];