问题
This question is related to Ag-Grid row height on Angular 4 Project. Please see the below scenario:-
I have an Ag-Gird having 3 columns respectively:-
- Id (resizable column from UI)
- Name (resizable column from UI)
- Address (resizable column from UI)
I do not have any limitations( like the limited number of character or words is allowed) on Address column. Users can type any number of characters or words they want to.
Issues:-
- How to increase the row height, when Address column width is completely filled-up with words or when users press Enter or Shift + Enter?
- How to adjust height automatically when users resize the Address column?
Please help me with these issues.
Thanks
回答1:
There are multiple things to be taken care.
Have a look at the updated Stackblitz
- Have
cellClass: "cell-wrap-text"
attribute in theColDef
forAddress
column and have the appropriate CSS - Handle
columnResized
event so thatthis.gridApi.resetRowHeights()
can be called to adjust the height of the rows whenever the column is resized Also handle
cellEditingStopped
event, so that when the data for the column is updated, the row height also gets updated accordingly.onColumnResized() { this.gridApi.resetRowHeights(); } onCellEditingStopped() { this.onColumnResized(); }
Provide
autoHeight: true
property in thedefaultColDef
defaultColDef = { autoHeight: true };
Update:
provide cellEditor: 'agLargeTextCellEditor'
if you want to have textarea
like control for this field.
Check this StackBlitz
来源:https://stackoverflow.com/questions/55263232/ag-grid-how-to-increase-row-height-dynamically