隐藏和显示columns-剑道网(hide and show columns- kendo grid

2019-10-28 15:47发布

如何隐藏和显示剑道网格​​的列不使用jQuery? 这里是JS拨弄链接,例如: 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"  }
    ];
}

谢谢。

Answer 1:

如果添加

columnMenu = TRUE,

列声明之前,这应该给你列菜单应使显示和隐藏列选项。

此链接应帮助

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



Answer 2:

在AngularJS鉴于你的剑道UI电网的名字,你的情况$scope.options

你可以隐藏每列编程方式传递列索引,这样的:

$scope.options.columns[3].hidden = true;


文章来源: hide and show columns- kendo grid