Skip to content

Problem with measuring column width #934

@doornik

Description

@doornik

The getColAutosizeWidth() function sets autoSize.colValueArray in certain cases.

Then getColContentSize() is called. This coerces autoSize.colValueArray to be of type RowInfo in the call to getColWidth.

That coercion means no fields are in common, and nothing is measured. A work around is to replace

    if (autoSize.colValueArray) {
      // if an array of values are specified, just pass them in instead of data
      maxColWidth = this.getColWidth(columnDef, gridCanvas, autoSize.colValueArray as any);
      return Math.max(autoSize.headerWidthPx, maxColWidth);
    }

with

    if (autoSize.colValueArray) {
      // if an array of values are specified, just pass them in instead of data
      const rowInfo = {} as RowInfo;
      rowInfo.startIndex = 0;
      rowInfo.endIndex = autoSize.colValueArray.length - 1;
      rowInfo.valueArr = autoSize.colValueArray;
      maxColWidth = this.getColWidth(columnDef, gridCanvas, rowInfo);
      return Math.max(autoSize.headerWidthPx, maxColWidth);
    }

I use the ability to specify my own value for measuring a column based on colValueArray to get around the inefficiencies inherent in the current implementation of GridAutosizeColsMode.IgnoreViewport.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions