问题
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.
回答1:
I would make use of rowSelection
api particularly the selected property of each rowNode
.
You can define getRowHeight
in html [getRowHeight]="getRowHeight"
and (selectionChanged)="onSelectionChanged($event)"
And define getRowHeight
like this -
this.getRowHeight = function(params) {
return params.node.selected ? 100 : 50; // if selected height is 100 else default 50
}
and then in your onSelectionChanged
,
onSelectionChanged() {
this.gridApi.resetRowHeights();
}
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.
来源:https://stackoverflow.com/questions/61908211/increase-height-of-a-specific-row