首页 > 解决方案 > 为什么无法识别 autoHeight 属性?

问题描述

我正在尝试使用autoHeight设置为 true 的属性创建一些列。但是,我不断收到以下警告:

ag-grid: invalid colDef property 'autoHeight' did you mean any of these: suppressAutoSize,headerTooltip,openByDefault,headerComponent,suppressSizeToFit,sort,headerGroupComponent,pivot
<...snip...>
ag-grid: to see all the valid colDef properties please check: https://www.ag-grid.com/javascript-grid-column-properties/

我的列定义如下所示:

const columnDefs = [
  {
    headerName: 'Id',
    field: 'id',
    filter: 'agTextColumnFilter',
    width: 90
  }, {
    headerName: 'Description',
    field: 'sportLeage',
    filter: 'agTextColumnFilter',
    autoHeight: true,
    valueGetter: params =>
      params.context.liveEventsController
        .createDescription(params.data),
    width: 90
  };

autoHeight被明确列为有效的列定义属性。虽然,在调试器中,我正在查看colDefUtil_1.ColDefUtil.ALL_PROPERTIES并且autoHeight不是可用属性之一。

我正在使用 ag-grid-enterprise v17.0.0。

我的想法是我的版本已过时或文档已过时。

标签: ag-grid

解决方案


在此处检查 v17.0.0类型定义代码ColDef

autoHeight不是 的属性ColDef

我目前在v17.1.1并被autoHeight宣布为number.

/** True if this column should stretch rows height to fit contents */
autoHeight?: number;

PS:评论表明它应该是一个boolean.
现在这让我想起了一句话
:)

代码从不说谎,但评论有时会说谎。


推荐阅读