2016-10-13 18 views
0

我一个kendogrid象下面这样:如何从columnmenu名单列在kendogrid

$("#grid-primaryUser").kendoGrid({ 
       dataSource: UserDataSource, 
       columns: [ 
        { 
         title: 'Is Approver', 
         template: "<input type='checkbox'/> 
        }, 
        { 
         title: 'First Name', 
         field: 'FirstName' 
        }, 
        { 
         title: 'Last Name', 
         field: 'LastName' 
        } 
       ], 
       toolbar: [ 
        { name: "save", text: app.common.resources.JS_.saveAll() } 
       ], 
       dataBound: function (e) { 
        var grid = $("#grid-primaryUser").data("kendoGrid"); 
        var isAPACRegionOffice = $('#IsAPACRegionOffice').val() == 'True' ? true : false; 
        if (grid != null && !isAPACRegionOffice) { 
         grid.hideColumn(0); 
         $("#grid-primaryUser").find(".k-grid-toolbar").detach(); 
        } 
       }, 
       height: 250, 
       groupable: false, 
       sortable: true, 
       pageable: false, 
       resizable: true, 
       reorderable: true, 
       columnMenu: { 
        messages: { 
         sortAscending: app.common.resources.JS_.kendoGridColumnMenuSortAscending(), 
         sortDescending: app.common.resources.JS_.kendoGridColumnMenuSortDescending(), 
         columns: app.common.resources.JS_.kendoGridColumnMenuColumns(), 
         unlock: app.common.resources.JS_Services_PropertyEventSearchService.kendoGridColumnMenuUnlock(), 
         lock: app.common.resources.JS_Services_PropertyEventSearchService.kendoGridColumnMenuLock() 
        } 
       }, 
       columnMenuInit: function (e) { 
        var item = e.container.find(".k-item k-state-default k-first"); 
        //item.prev(".k-separator").remove(); 
        item.remove(); 
       } 
      }); 

在这里我可以根据条件是真还是在“数据绑定”属性假隐藏的第一列,但在columnMenu列表中它仍然显示,如果它隐藏在网格中(来自数据绑定函数),并且这需要在运行时完成,那么我需要从列菜单列表中删除第一列。

我试图使用'ColumnMenuInit'属性来做到这一点,但这似乎不起作用,或者我可能会丢失一些东西。

回答