Angular agGrid的自动行高属性不起作用
我在我的项目中使用角度网格。我想在单元格内容增加时自动增加行高。我选中了autoHeight属性以设置为auto,但它在我的情况下不起作用 在我的例子中,OldRequestNumber可以包含跨多行的多个数据。在下面应用时,它仅显示列表中的第一个事件,列表中还有更多 HTML页面Angular agGrid的自动行高属性不起作用,angular,ag-grid,row-height,Angular,Ag Grid,Row Height,我在我的项目中使用角度网格。我想在单元格内容增加时自动增加行高。我选中了autoHeight属性以设置为auto,但它在我的情况下不起作用 在我的例子中,OldRequestNumber可以包含跨多行的多个数据。在下面应用时,它仅显示列表中的第一个事件,列表中还有更多 HTML页面 <ag-grid-angular style="width: 100%; height: 200px" class="ag-theme-balham"
<ag-grid-angular style="width: 100%; height: 200px"
class="ag-theme-balham"
[pagination]="true"
[gridOptions]="genderGridOptions"
[rowData]="genderRowData"
[columnDefs]="genderColDef"
(gridReady)="onGridReady($event)">
</ag-grid-angular>
<ag-grid-angular style="width: 100%; height: 200px"
class="ag-theme-balham"
[pagination]="true"
[gridOptions]="genderGridOptions"
[rowData]="genderRowData"
[columnDefs]="genderColDef"
[getRowHeight]="getRowHeight" //Added this line
(gridReady)="onGridReady($event)">
</ag-grid-angular>
单元格渲染器HTML
<div *ngFor="let req of params.data.OldRequestNumber">
{{req.RequestNumber}}
</div>
如何实现此功能?为了实现此功能,我做了以下更改:- HTML页面
<ag-grid-angular style="width: 100%; height: 200px"
class="ag-theme-balham"
[pagination]="true"
[gridOptions]="genderGridOptions"
[rowData]="genderRowData"
[columnDefs]="genderColDef"
(gridReady)="onGridReady($event)">
</ag-grid-angular>
<ag-grid-angular style="width: 100%; height: 200px"
class="ag-theme-balham"
[pagination]="true"
[gridOptions]="genderGridOptions"
[rowData]="genderRowData"
[columnDefs]="genderColDef"
[getRowHeight]="getRowHeight" //Added this line
(gridReady)="onGridReady($event)">
</ag-grid-angular>
希望有帮助。它会像这样工作。试试下面的方法
{headerName:'Date',field:'Date',width:175,cellStyle:{“空白”:“normal”},autoHeight:true},
包括cellStyle:{“空白”:“正常”}那么只有它才能工作。您可以添加stackblitz代码或类似代码吗?
ngOnInit()
{
this.genderCommonService.getEntityData('getallgenders')
.subscribe((rowData) => {
rowData.forEach(function (dataItem: any, index) {
dataItem.rowHeight = 25 * dataItem.OldRequestNumber.length;
});
this.genderRowData = rowData
},
(error) => { alert(error) }
);
}
constructor(private genderCommonService: CommonFunctionService, private genderCellValueService: CellValueChangedService) {
this.getRowHeight = function (params : any) {
return params.data.rowHeight;
};
}