Extjs网格面板 - 隐藏具有hideable = false的列 [英] Extjs Grid panel - Hide a column with hideable=false

查看:256
本文介绍了Extjs网格面板 - 隐藏具有hideable = false的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Extjs 4.1网格面板。

i'm using Extjs 4.1 grid panel.

我正在寻找一种方法来隐藏网格中的列。
我可以使用setHidden,但用户可以从列标题的菜单中再次取消隐藏列。
似乎可隐藏的属性只是没有剪切...

i'm looking for a way to hide a column from the grid. i can use setHidden but then the user can "unhide" the column again from the menu in the column header. it seems that the hideable propery just doesnt cut it...

推荐答案

好的。
最终我这样做:
在网格的afterrender事件中:

Ok. Eventually i did this: in the grid's "afterrender" event:

var header = pnl.down("headercontainer");
if(header != null && header["getMenu"] != null)
{
   var menu=header.getMenu();
   menu.on('beforeshow',function(sender,eOpts){

            var menu=sender;
            if(!menu.items.containsKey("columnItem"))
            {
                return;
            }

            var columnsSubMenuItem=menu.items.getByKey("columnItem");
            var columnsCheckboxes=columnsSubMenuItem.menu.items["items"];

            // More code here...
            // See the pseudo code
   });
}

现在我刚刚循环了列,如果checkbox.text ==列。 get_Title()&& column.get_Hideable()== true then checkbox.Show()else checkbox.Hide();

now i just looped through the columns and if checkbox.text == column.get_Title() && column.get_Hideable() == true then checkbox.Show() else checkbox.Hide();

(对于伪代码,我很喜欢Sharpkit,一个C#到javascript转换器,所以如果我复制粘贴代码,这将更难解释。

(sorry for the pseudo code, i work with a Sharpkit that is a C# to javascript convertor, so if i'd copy pasted the code it'd be harder to explain.

注意:你可以对网格的enableColumnHide事件做同样的事情。

Note: you can do the same with the grid's enableColumnHide event.

这篇关于Extjs网格面板 - 隐藏具有hideable = false的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆