increase height of a specific row

房东的猫 提交于 2020-06-29 04:32:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!