[CLOSED] Show/Hide grid columns
Hi all,
I have a grid with two columns.
The grid is inside a panel and the latter has a toolbar with two toggle buttons in it.
The initial situation is as following: the first button is pressed and the first grid column's visible while the second one's hidden.
When toggling the second button, I need to show the second column and hide the first one (and when toggling the first button, I need to show the first column and hide the second one).
I cannot understand how to access the grid's columns, can you help me? I think it should be something like MyGrid.getColumnById(1).hide() or MyGrid.getColumnById(1).show(); should be the same code called when a user shows/hides a column by the grid's header..
Thanks in advance,
RE: [CLOSED] Show/Hide grid columns
Hi,
Use ColumnModel
Code:
MyGrid.getColumnModel().setHidden(0, true);
http://www.extjs.com/deploy/dev/docs...id.ColumnModel
RE: [CLOSED] Show/Hide grid columns
RE: [CLOSED] Show/Hide grid columns
Just another question: is it possible to do the same thing in code behind?
Thanks,
RE: [CLOSED] Show/Hide grid columns
Hi,
Yes
Code:
MyGrid.ColumnModel.SetHidden(0, true);
RE: [CLOSED] Show/Hide grid columns
Thanks a lot, you can mark this topic as solved.
RE: [CLOSED] Show/Hide grid columns
Hey Vladsch,
That is really helpful but i have a problem in displaying my hidden column after i hide it.
The code is below:(VB.Net)
If A = "OFF" Then
GridPanel.ColumnModel.SetHidden(7, True)
Else
GridPanel.ColumnModel.SetHidden(7, False)
End If
I check wether A is ON r OFF on my every pageload . So if A is OFF in the first pageload, grid is hiding the column but on second pageload A will be ON but grid is not displaying the hidden column. This grid is placed inside an panel.
It displays the hidden column if i bind data to it but i want to hide r display before i bind data.
Is there any proprty to make grid automatically take the changes made to it and show them immediately.
I need your help on this
I tried these to make grid to accept changes immediadely.
If A = "OFF" Then
studentGridPanel.ColumnModel.SetHidden(7, True)
studentGridPanel.AutoLoad.AutoDataBind = True
studentGridPanel.AutoShow = True
studentGridPanel.AutoDataBind = True
Else
entryGridPanel.ColumnModel.Columns(7).Hidden = False
studentGridPanel.RefreshView()
studentGridPanel.AutoShow = True
studentGridPanel.AutoDataBind = True
End If
Thanks in advance
DineshReddi