调整 Ag Grid 中的特定列大小。

huangapple go评论85阅读模式
英文:

resize a specific column in ag grid

问题

我在Ag Grid中启用了分组功能。

由于我可能有多级分组(在2或3个不同的列上),我希望在用户单击分组以展开时调整分组列的大小。

我使用onRowGroupOpened来实现这一点,代码如下:

onRowGroupOpened: function(params) { ResizeGroupColumn(params); },

在我的ResizeGroupColumn函数中,我正在做以下操作:

function ResizeGroupColumn(params) {
  var groupCol = params.columnApi.getAllColumns().map(col => col.colDef['rowGroup'] === true);
  // 但是这会返回所有列。我只想返回`rowGroup`属性设置为true的列。
  // 是否有更好的方法来实现这一点?
}

请注意,代码部分不进行翻译,只提供翻译好的内容。

英文:

I have a Group by functionality enabled in my Ag Grid.

Since I might have multi level grouping (on 2 or 3 different columns) I would like to resize the Group column once user clicks on the Grouping to drill down.

I am using onRowGroupOpened to achieve this like so:

onRowGroupOpened: function(params) { ResizeGroupColumn(params); },

In my ResizeGroupColumn function here's what I'm doing...

function ResizeGroupColumn(params) {

  var groupCol = params.columnApi.GetAllColumn().map(col=>col.colDef['rowGroup'] =true);

  //however this returns all the columns. I'm only trying to return the column that has 'rowGroup' set to true. 

 //is there a better way to do this?

}

答案1

得分: 1

将以下部分翻译为中文:

从:

colDef['rowGroup'] = true

改为:

colDef['rowGroup'] === true

英文:

You are doing an assignment where you think that you are doing a comparison.
Probably a simple typo.

change

colDef['rowGroup'] =true

to

colDef['rowGroup'] === true

huangapple
  • 本文由 发表于 2023年2月10日 03:49:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75403739.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定