Kendo Grid列隐藏/显示,启用/禁用

Apu*_*ukh 21 kendo-ui kendo-grid

如何在条件或事件中隐藏/显示和启用/禁用剑道网格中的列.我只能在.model中找到启用/禁用kendogrid列的选项

任何帮助表示赞赏.

先感谢您!

Ona*_*Bai 33

您显示/隐藏列KendoUI网格,你应该使用showColumn,并hideColumn与作为参数使用数字(要显示/隐藏的列的索引)或字符串(在列关联的字段的名称).

例:

var grid = $("#grid").kendoGrid({
    dataSource: ds,
    editable  : false,
    pageable  : true,
    columns   :
    [
        { field: "FirstName", width: 90, title: "First Name" },
        { field: "LastName", width: 90, title: "Last Name" },
        { field: "City", width: 100 }
    ]
}).data("kendoGrid");

$("#show_col1").on("click", function() {
    // Use the index of the column to show
    grid.showColumn(0);
});

$("#hide_col1").on("click", function() {
    // Use the name of the field to hide it
    grid.hideColumn("FirstName");
});
Run Code Online (Sandbox Code Playgroud)

您可以通过hidden在列初始化中进行设置来控制是否应该最初隐藏列.

在这里查看示例:http://jsfiddle.net/OnaBai/XNcmt