增加特定行的高度 [英] increase height of a specific row
问题描述
最初,所有行的高度都将保持为50。当一个单元格被聚焦时,如果它具有更多的内容并且需要更高的高度,则需要增加该特定单元格的高度。如果不可能,则必须增加整个特定行的高度。其余行不应该生效。
Initially, all rows will have the same height of 50. When a cell is focused,if it has more content and requires more height, I need to increase the height of that particular cell. If that is not possible, atleast that entire particular row's height has to be increased. The remaining rows should not get effected.
推荐答案
我会使用 rowSelection
api,尤其是每个 rowNode
的 selected 属性。
I would make use of rowSelection
api particularly the selected property of each rowNode
.
您可以在html [getRowHeight] = getRowHeight $中定义
getRowHeight
c $ c>
和(selectionChanged)= onSelectionChanged($ event)
You can define getRowHeight
in html [getRowHeight]="getRowHeight"
and (selectionChanged)="onSelectionChanged($event)"
getRowHeight
像这样-
this.getRowHeight = function(params) {
return params.node.selected ? 100 : 50; // if selected height is 100 else default 50
}
,然后在您的 onSelectionChanged
,
onSelectionChanged() {
this.gridApi.resetRowHeights();
}
您希望在选定的选项上back带的原因
属性是因为它由ag-grid为每一行维护。
您可以通过实现回调 onCellFocused
来执行类似的操作但是随后您将必须为每行维护一个相似的属性,因为一旦焦点所在的行失去焦点,您还需要调整高度,这可能是一项昂贵的操作。
The reason you would want to piggyback on selected
attribute is because it is maintained by ag-grid for each row.
You could do something similar by implementing the callback onCellFocused
but then you will have to maintain a similar attribute for each row because you also need to adjust the height once the focused row is out of focus which might be an expensive operation.
这篇关于增加特定行的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!