英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论