隐藏和显示列 - 剑道网格

时间:2014-06-16 07:18:24

标签: kendo-ui kendo-grid angular-kendo

如何在不使用jquery的情况下隐藏和显示kendo网格列? 这里是示例的js小提琴链接:http://jsfiddle.net/tmLmk/7/

HTML code:

<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"  }
    ];
}

感谢。

2 个答案:

答案 0 :(得分:2)

如果你添加

columnMenu = true,

在列声明之前,这应该为您提供列菜单,该菜单应该启用show和hide列选项。

此链接应该有帮助

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

答案 1 :(得分:0)

根据AngularJS中 Kendo UI网格的名称,在您的情况下 select coalesce(main.checkby, 'Total') as checkby_or_total, lfaulty, lfully, ltotal, dfaulty, dfully, dtotal, wfaulty, wfully, wtotal, mfaulty, mfully, mtotal from ( select qcheck.checkby, count(case result when 'fully tested & working' then 1 end) as mfully, count(case result when 'faulty' then 1 end) as mfaulty, count(*) as mtotal from qcheck where YEAR(finishdate) = YEAR(CURDATE()) AND MONTH(finishdate) = MONTH(CURDATE()) and qcheck.checkby not like 'michael' and qcheck.checkby not like 'chaz' group by qcheck.checkby with rollup ) as main Left join ( select qcheck.checkby, count(case result when 'fully tested & working' then 1 end) as dfully, count(case result when 'faulty' then 1 end) as dfaulty, count(*) as dtotal from qcheck where finishdate >= now()-interval 12 hour and qcheck.checkby not like 'michael' and qcheck.checkby not like 'chaz' group by qcheck.checkby with rollup) as today on today.checkby =main.checkby Left join ( select qcheck.checkby, count(case result when 'fully tested & working' then 1 end) as wfully, count(case result when 'faulty' then 1 end) as wfaulty, count(*) as wtotal from qcheck where YEARWEEK(finishdate)=YEARWEEK(NOW()) and qcheck.checkby not like 'michael' and qcheck.checkby not like 'chaz' group by qcheck.checkby with rollup) as week on week.checkby =main.checkby Left join ( select qcheck.checkby, count(case result when 'fully tested & working' then 1 end) as lfully, count(case result when 'faulty' then 1 end) as lfaulty, count(*) as ltotal from qcheck where finishdate >= now()-interval 1 hour and qcheck.checkby not like 'michael' and qcheck.checkby not like 'chaz' group by qcheck.checkby with rollup) as month on month.checkby =main.checkby order by main.checkby is null, mtotal desc

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

$scope.options