指定行的最小高度,同时保留自动高度功能 - Ag-grid

val*_*gar 6 javascript height row ag-grid

我想将每个 ag-grid 行的最小高度指定为 40px,并允许任何超过 40px 的行使用动态高度。

      this.gridOptions = {
        /* rowHeight : 40, */
        headerHeight: 100,
        pagination: true,
        enableSorting: true,
        enableColResize: true,
        rowDeselection: true,
        suppressHorizontalScroll: false,
        autoHeight: true
      };
Run Code Online (Sandbox Code Playgroud)

gridOptions.autoHeight让我动态更改高度,但分配类似gridOptions.rowHeight 的内容或使用getRowHeight(params)设置默认的最小高度会覆盖 autoHeight。有办法解决这个问题吗?

val*_*gar 2

设法解决了这个问题,在这里为可能遇到同样问题的其他人发布答案:

我需要更改一些内容:

  1. 我使用的 ag-grid 版本(13.1.2)似乎不支持 autoHeight 功能。将 ag-grid 更新到版本 18.1.2,将 ag-grid-vue 更新到 18.1.0(我使用的是 Vue.js 框架)。
  2. 我错误地使用了 autoHeight 选项。我需要使用autoHeight: true; 在配置确定行高的每一列时,而不是在 gridOptions 中。

这些步骤根据内容调整行的高度。

  1. 添加rowHeight: 40px; 在 gridOptions 中,设置应用 autoHeight 后行的最小高度。