PDA

View Full Version : Collapse/Expand Contentpanel



flyingbo
12 May 2009, 4:20 AM
Hello @ all,

i´ve got a problem with a contentpanel and the functions expand() and collapse().


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.



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

takayser
13 May 2009, 11:52 AM
not sure if I understand your problem, but if so -> use else if


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

flyingbo
13 May 2009, 10:15 PM
Hey thanks for your reply!

Sorry i post only e short codefragment, here´s the full 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

takayser
15 May 2009, 1:18 AM
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.

stan229
15 May 2009, 11:56 AM
are you doing anything else with that cp outside the scope of what you showed us?

jschwarz0
17 May 2009, 2:58 PM
you might try a cp.layout() after changing the state.
ymmv...

flyingbo
17 May 2009, 10:16 PM
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!