如何在 extjs 3 网格面板中显示/隐藏列 [英] how to show/ hide column in a extjs 3 grid panel

查看:30
本文介绍了如何在 extjs 3 网格面板中显示/隐藏列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网格面板,我需要根据复选框的值在网格面板中显示/隐藏列.如果选中复选框,我需要在网格中显示列,如果未选中,我需要隐藏网格中的列.

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屋!

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