PDA

View Full Version : [CLOSED] 2.x Hide Grid columns on client side



omazlov
Sep 05, 2012, 8:54 PM
Hi,

How can I hide column on client side, when I click a button?

this code works well in EXT.NET 1.0


if (#{grid1}.getColumnModel().isHidden(6))
{
#{grid1}.getColumnModel().setHidden(6, false);
}

but does not work in version Ext.NET 2.0. Any help?

Thanks in advance

Daniil
Sep 06, 2012, 7:42 AM
Hi,

We are glad to see you on the Ext.NET forums!

The problem is related to the CHANGELOG items #12 and #18.



12. Column .ColumnID has been renamed to .ID

Now Column is a component and registered in ComponentMgr (http://www.sencha.com/forum/showthread.php?133562)

Example

//Old <ext:Column ColumnID="company">

//New <ext:Column ID="company" runat="server">



18. ColumnModel .SetHidden() has been removed.

Use Column .Hidden

Example

//Old this.GridPanel1.ColumnModel.SetHidden(2, true);

//New this.GridPanel1.ColumnModel.Columns[2].Hidden = true;

The CHANGELOG is online:
http://examples2.ext.net/#/Getting_Started/Release_Documents/CHANGELOG/
and in the sources.

The above CHANGELOG items means that you can the following.

1. Specify an ID for the Column, for example, "Column1" and call just:

App.Column1.hide();

2. If you need to access a Column by index, please use this code:

App.GridPanel1.columns[index].hide();


My best thoughts regarding migration from v1 to v2 are here:
http://forums.ext.net/showthread.php?18358&p=79239&viewfull=1#post79239

omazlov
Sep 06, 2012, 2:32 PM
Thank you Daniil,

Please mark the issue is resolved.

I have applied the following code which is work in EXT.NET 2.x


if (App.grid1.columns[6].isHidden()) {
App.grid1.columns[6].show();
}
else {
App.grid1.columns[6].hide();
}

Daniil
Sep 06, 2012, 2:44 PM
Also you can use the setVisible function.
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.AbstractComponent-method-setVisible

Example

var col = App.grid1.columns[6];

col.setVisible(col.isHidden());

omazlov
Sep 07, 2012, 2:32 PM
Thank you Daniil.

It is a good advice :)