【问题标题】:Collapse Kendo UI Grid details programmatically in Angular application在 Angular 应用程序中以编程方式折叠 Kendo UI Grid 详细信息
【发布时间】:2018-02-21 15:08:11
【问题描述】:

我有一个带有 kendo UI 库的 angular 5 应用程序。在这个应用程序中,我有一个 Kendo UI Grid,其中包含一些行的详细信息。网格也是可排序的。 当我单击列名对数据进行排序时,我想折叠所有展开的详细信息。

这是我的 html 代码:

<kendo-grid
#grid
[kendoGridBinding]="getDataService().listOfSolution"
[resizable]="false"
[pageSize]="10"
[pageable]="true"
[sortable]="true"
[filterable]="false"
[groupable]="false"
[reorderable]="false"
[selectable]="false"
[scrollable]="'none'"
(dataStateChange)="onSort($event)"
[rowClass]="rowCallback()"
(detailCollapse)="onCollapse($event)"
(detailExpand)="onExpand($event)"
style="border: none;">
...
</kendo-grid>

但我找不到以编程方式关闭详细信息的方法。

你有什么想法吗?

【问题讨论】:

    标签: angular kendo-ui kendo-grid


    【解决方案1】:

    您可以通过 collapseRow 函数 (API Reference) 折叠主行。

    您可以在下面找到一个示例,说明如何处理您的特定用例。

    @Component({ ... })
    export class MyComponent {
        onExpand(event) {
            // keep track of all expanded rows (index)
        }
    
        onCollapse(event) {
            // keep track of all expanded rows (index)
        }
    
        onSortChange(event) { // either (sortChange) or (dataStateChange)
            // iterate all expanded rows & collapse them via `this.grid.collapseRow(index)`
        }
    }
    

    【讨论】:

    • 感谢您的回答。但是什么是“this.grid”,它来自哪里?
    • 您可以像这样定义模板变量:#grid。然后通过 TypeScript 中的ViewChild 访问它。
    猜你喜欢
    • 1970-01-01
    • 2020-01-27
    • 2011-03-27
    • 2020-10-26
    • 1970-01-01
    • 1970-01-01
    • 2020-11-08
    • 2015-01-15
    • 1970-01-01
    相关资源
    最近更新 更多