0

如何在不使用 jquery 的情况下隐藏和显示剑道网格​​的列?这是示例的 js fiddle 链接:http: //jsfiddle.net/tmLmk/7/

HTML 代码:

<div ng-controller="GridController">    
    <div kendo-grid k-options="options" k-data-source="sData"></div>
</div>

JS代码:

angular.module('angular-kendo-example', ['kendo.directives']);

function GridController($scope) {
    $scope.options = {
        sortable: true,
        pageable: true,
        columns: [{
            field: "column1",
            title: "column 1",
            width: "40px"
        },{
            field: "column2",
            title: "column 2",
            width: "70px"
        },{
            field: "column3",
            title: "column 3",
            width: "70px"
        },{
            field: "column4",
            title: "column 4",
            width: "60px"
        },{
            field: "column5",
            title: "column 5",
            width: "40px"
        },{
            field: "column6",
            title: "column 6",
            width: "40px"
        }],

    };
    $scope.sData= [
        { column1: "column1 data", column2: "column2 data", column3: "column3 data", column4:  "column4 data",  column5: "column5 data", column6: "column6 data"  }, { column1: "column1 data", column2: "column2 data", column3: "column3 data", column4:  "column4 data",  column5: "column5 data", column6: "column6 data"  }, { column1: "column1 data", column2: "column2 data", column3: "column3 data", column4:  "column4 data",  column5: "column5 data", column6: "column6 data"  }
    ];
}

谢谢。

4

2 回答 2

2

如果你添加

列菜单=真,

在声明列之前,这应该为您提供列菜单,该菜单应该启用显示和隐藏列选项。

这个链接应该有帮助

http://demos.telerik.com/kendo-ui/grid/column-menu

于 2014-06-16T20:24:27.717 回答
0

给定AngularJS 中 Kendo UI Grid的名称,在您的情况下$scope.options

您可以通过列索引以编程方式隐藏每一列,如下所示:

$scope.options.columns[3].hidden = true;
于 2016-06-23T09:43:37.753 回答