1. #1
    Sencha Premium Member
    Join Date
    Aug 2008
    Posts
    16
    Vote Rating
    0
    flyingbo is on a distinguished road

      0  

    Default Collapse/Expand Contentpanel

    Collapse/Expand Contentpanel


    Hello @ all,

    i´ve got a problem with a contentpanel and the functions expand() and collapse().
    Code:
    ContentPanel cp = new ContentPanel();
    cp.setBorders(true);
    cp.setHeaderVisible(true);
    cp.setLayout(new FitLayout());
    cp.setAnimCollapse(false);
    cp.setCollapsible(true);
    BorderLayoutData data = new BorderLayoutData(LayoutRegion.WEST,100);
    data.setMargins(new Margins());
    data.setCollapsible(true);
    viewport.add(cp, data);
    after this i would collapse or expand the contentpanel by buttonclick.

    Code:
    if(cp.isExpanded()){
      cp.collapse();
    }
    if(cp.isCollapsed()){
      cp.expand();
    }
    The first time i clicked the button, the contentpanel expand and after it collapse. but after the second click the contentpanel don´t expand. I checked this with the debugger and it´s all fine. the cp.expand()-command execute but there are no changes happen in the gui.

    Can anybody help?

    Thanks and best wishes
    Chris

  2. #2
    Ext GWT Premium Member takayser's Avatar
    Join Date
    Oct 2008
    Location
    Lucerne, Switzerland
    Posts
    188
    Vote Rating
    0
    takayser is an unknown quantity at this point

      0  

    Default


    not sure if I understand your problem, but if so -> use else if

    Code:
    if(cp.isExpanded()){
      cp.collapse();
    }
    else if(cp.isCollapsed()){
      cp.expand();
    }

  3. #3
    Sencha Premium Member
    Join Date
    Aug 2008
    Posts
    16
    Vote Rating
    0
    flyingbo is on a distinguished road

      0  

    Default


    Hey thanks for your reply!

    Sorry i post only e short codefragment, here´s the full code:
    Code:
            if(event.getType().equals(AppEvents.SHOW_CHOOSE_ARCHIVE)){
                ContentPanel cp = Registry.get(AppView.WEST_PANEL);
                if(cp != null){
                    if(cp.isExpanded()){
                        cp.collapse();
                    }
                    Dispatcher.get().dispatch(AppEvents.REFRESH_ARCHIVE_GRID);
                }
            }else if(event.getType().equals(AppEvents.SHOW_SEARCH_FRONTEND)){
                ContentPanel cp = Registry.get(AppView.WEST_PANEL);
                if(cp != null){
                    if(cp.isCollapsed()){
                        cp.expand();
                    }
                }
            }
    My problem:
    I wan´t to expand a contentpanel, if the user clicks on a button and collapse if the user clicks on another button. Initially the contentpanel is collapsed.
    The first time i click the button to expand the panel, it work´s fine. After this i collapse the panel by clicking another button. --> it work´s
    After this steps i click the button to expand again but nothing happens. So i tried to use the debugger and it shows me, that the code executed rightly and the cp.expand() executed but nothing changes in the gui.
    Could it be a bug in GWT EXT?

    Thanks again and wishes
    Chris

  4. #4
    Ext GWT Premium Member takayser's Avatar
    Join Date
    Oct 2008
    Location
    Lucerne, Switzerland
    Posts
    188
    Vote Rating
    0
    takayser is an unknown quantity at this point

      0  

    Default


    so if it acts like you described, write executable sample code in a onModuleLoad method and post it in the bug forum or in here.

  5. #5
    Ext GWT Premium Member
    Join Date
    Apr 2009
    Location
    NYC
    Posts
    112
    Vote Rating
    1
    stan229 is on a distinguished road

      0  

    Default


    are you doing anything else with that cp outside the scope of what you showed us?

  6. #6
    Ext User
    Join Date
    Jun 2008
    Posts
    18
    Vote Rating
    0
    jschwarz0 is on a distinguished road

      0  

    Default


    you might try a cp.layout() after changing the state.
    ymmv...

  7. #7
    Sencha Premium Member
    Join Date
    Aug 2008
    Posts
    16
    Vote Rating
    0
    flyingbo is on a distinguished road

      0  

    Default


    i found the problem. all components are added to a viewport with borderlayout and regions.
    now i use (borderlayout viewport).expand(LayoutRegion.WEST) and not (contentpanel or borderlayout contentpanel).expand().

    thanks for help!