如何在extjs 3网格面板中显示/隐藏列 [英] how to show/ hide column in a extjs 3 grid panel
问题描述
我有一个网格面板,我需要根据复选框的值显示/隐藏网格面板中的列。如果选中该复选框,我需要在网格中显示列,如果不选中,我需要隐藏网格中的列。
I have a grid panel i need to show / hide columns in a grid panel depending on the value of a checkbox. If the checkbox is checked i need to display column in the grid and if it is unchecked i need to hide the column in the grid.
这是我的代码
var chkEnableDisplayResponsibilityForAction = '<%=Session["chkEnableDisplayResponsibilityForAction"]%>';
var flags = Boolean.parse(chkEnableDisplayResponsibilityForAction);
var flags1 = !Boolean.parse(chkEnableDisplayResponsibilityForAction)
var colModel = new Ext.grid.ColumnModel([
{ header: "PricePlanID", width: 100, sortable: true, dataIndex: 'PricePlanID', hidden: flags, hideable: flags1 },
]);
当我刷新页面时,我无法根据复选框的值切换列。但是当我登录并注销时,我可以看到网格面板中的更改。任何人都可以帮助我刷新网格面板中的列值?
when i refresh the page i am not able to toggle the columns depending on the value of the checkbox. But when i login and log out i am able to see the changes in the grid panel. Can anyone help me in refreshing the column values in the grid panel?
推荐答案
如果看看ExtJS API,特别是 ColumModel 有一个 setHidden
方法,它将隐藏/显示一个 GridPanel
中的列。
if take a look at the ExtJS API, particulary the ColumModel there is a setHidden
method, it would hide/show a column in a GridPanel
.
myGrid.getColumnModel().setHidden(0, true);
你还应该钩住 onchange
您的复选框,以便您可以显示或隐藏列
you should also hook the onchange
event of your check box so you can show or hide the column
这篇关于如何在extjs 3网格面板中显示/隐藏列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!