如何增加ag-grid中列标题的高度?

时间:2016-03-08 10:13:31

标签: javascript jquery angularjs ag-grid

  

有没有办法像我们对宽度那样增加列标题的高度。我需要这个,因为我在标题中嵌入了一个饼图,并且绑定了但是列太短而无法完全显示。有没有办法增加列标题的大小。

4 个答案:

答案 0 :(得分:6)

gridOptions中有一个属性headerHeight

检查https://www.ag-grid.com/javascript-grid-properties/index.php

答案 1 :(得分:2)

您还可以使用grid api根据标题内容添加运行时:

onGridReady(params) {
    this.gridApi = params.api;
    this.gridApi.setHeaderHeight(<set your header height in pixel>);
}

onGridReady()函数绑定到gridReady事件,如下所示:

<ag-grid-angular(gridReady)="onGridReady($event)> </ag-grid-angular>

答案 2 :(得分:0)

Header Height属性也可以像这样直接在网格组件上设置:

<ag-grid-vue style="width: 100%;height: 47vh;"
    class="ag-theme-balham"
    :columnDefs="columnDefs"
    :rowData="rowData"
    headerHeight="50">
</ag-grid-vue>

答案 3 :(得分:0)

检查列标题文档https://www.ag-grid.com/javascript-grid-column-header/

两个选项

1-可用于更改不同高度的属性

<ag-grid-angular
    [columnDefs]="columnDefs"
    [rowData]="rowData"
    [headerHeight]="headerHeight"
    [groupHeaderHeight]="groupHeaderHeight"
    [floatingFiltersHeight]="floatingFiltersHeight"
    [pivotGroupHeaderHeight]="pivotGroupHeaderHeight"
    [pivotHeaderHeight]="pivotHeaderHeight"
></ag-grid-angular>

2- setter方法,可以从API调用

<ag-grid-angular
    [columnDefs]="columnDefs"
    [rowData]="rowData"
    (gridReady)="onGridReady($event)"
 ></ag-grid-angular>

onGridReady(params) {
    this.gridApi = params.api;
    this.gridColumnApi = params.columnApi;
}

setHeaderHeight(value) {
    this.gridApi.setHeaderHeight(value);
    setIdText('headerHeight', value);
}

setGroupHeaderHeight(value) {
    this.gridApi.setGroupHeaderHeight(value);
    setIdText('groupHeaderHeight', value);
}

setFloatingFiltersHeight(value) {
    this.gridApi.setFloatingFiltersHeight(value);
    setIdText('floatingFiltersHeight', value);
}

setPivotGroupHeaderHeight(value) {
    this.gridApi.setPivotGroupHeaderHeight(value);
    setIdText('pivotGroupHeaderHeight', value);
}

setPivotHeaderHeight(value) {
    this.gridApi.setPivotHeaderHeight(value);
    setIdText('pivotHeaderHeight', value);
}