applyFieldOverrides with custom.width

I’m creating a plugin that involves using the @grafana/ui Table component. Right now I’m facing the issue that when I’m calling applyFieldOverrides with a custom.width property it doesn’t end up getting reflected in the DataFrame.

I can get overrides to work where the property.id is on the FieldConfigProperty. However when I try to use an override like this, it doesn’t end up in the DataFrame.fields.config.custom.width.

{
      matcher: {
        id: FieldMatcherID.byName,
        options: fieldDisplayName,
      },
      properties: [
        {
          id: 'custom.width',
          value: width,
        },
      ],
    }

I face the same issue with using custom.hidden and simply had to go modify the DataFrame manually after calling applyFieldOverrides but this feels so janky and I’m manually rewriting what applyFieldOverrides is supposed to be doing.

These seem to work fine when applying overrides to Grafana’s native TablePanel. This is obviously only a portion of the implementation but I’m getting the fieldDisplayName and width from the Table’s onColumnResize. Very similar to https://github.com/grafana/grafana/blob/main/public/app/plugins/panel/table/TablePanel.tsx#L86

const overrides = [{
      matcher: {
        id: FieldMatcherID.byName,
        options: fieldDisplayName,
      },
      properties: [
        {
          id: 'custom.width',
          value: width,
        },
      ],
    }];
let overriddenData = applyFieldOverrides({
      data: [modifiedFrame],
      fieldConfig: {
        overrides,
        defaults: {},
      },
      theme,
      replaceVariables: (value: string, scopedVars?: ScopedVars) => {
        return getTemplateSrv().replace(value, scopedVars);
      },
    })[0];
// at this point I would expect the field to have config.custom.width to be set but it isn't

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.