冻结列标题Kendo grid Angular 2

时间:2017-11-24 09:34:13

标签: angular kendo-grid

如何在垂直滚动网格的同时冻结剑道网格的标题行(就像我们在excel中'冻结窗格'一样)?在阅读了kendo-grid api之后,我尝试在[headerStyle]="{'position': 'fixed'}"标记中使用kendo-grid-column但它使所有标题相互重叠。任何建议都很明显。

1 个答案:

答案 0 :(得分:1)

在这种情况下,你必须设置grid的scrollable ='scrollable'属性并将gridContent设置为overflow-y auto。

.k-grid-content {
    height: inherit;
    overflow-y: auto;
}

在HTML中设置网格如下:

<kendo-grid id="grdView" 
        [ngStyle]="setStyles()"
        [data]="yourDatabse"
        [scrollable]="'scrollable'"
        [height]="gridNewHeight"
>

然后在后端设置gridContent高度,如下所示:

let height:number=300;
public setStyles(): any {
    this.gridNewHeight = this.height;

    let styles = {
        'height': (this.gridNewHeight - 45) + 'px'
    };

    let gridHeaderHeight: number =40;

    let gridContent: any = this.el.nativeElement.getElementsByClassName('k-grid-content')[0];
    if (gridContent != null) {
       gridContent.style.height = (this.gridNewHeight - (gridHeaderHeight )) + 'px';
    }

    return styles;
}