[CLOSED] Show/Hide grid columns

  1. #1

    [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,


  2. #2

    RE: [CLOSED] Show/Hide grid columns

    Hi,

    Use ColumnModel
    MyGrid.getColumnModel().setHidden(0, true);

    http://www.extjs.com/deploy/dev/docs...id.ColumnModel
  3. #3

    RE: [CLOSED] Show/Hide grid columns

    Thank you Vlad!
  4. #4

    RE: [CLOSED] Show/Hide grid columns

    Just another question: is it possible to do the same thing in code behind?
    Thanks,
  5. #5

    RE: [CLOSED] Show/Hide grid columns

    Hi,

    Yes
    MyGrid.ColumnModel.SetHidden(0, true);
  6. #6

    RE: [CLOSED] Show/Hide grid columns

    Thanks a lot, you can mark this topic as solved.
  7. #7

    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

Similar Threads

  1. hide columns Grid Ext 2.0
    By sysmo in forum 2.x Help
    Replies: 3
    Last Post: Jun 15, 2012, 7:07 PM
  2. Replies: 1
    Last Post: Dec 28, 2011, 6:36 PM
  3. [CLOSED] Show Hide Grid Panel from runtime
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 23, 2011, 6:32 PM
  4. GridPanel Hide/Show Columns
    By vs.mukesh in forum 1.x Help
    Replies: 1
    Last Post: Oct 30, 2010, 4:29 PM
  5. [CLOSED] Show/hide GridPanel columns during DirectEvent
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 20, 2010, 8:51 PM

Posting Permissions