View Full Version : ContentPanel with ButtonBar
kcaseye
05-02-2008, 09:50 AM
I can't seem to get the built in ButtonBar in the ContentPanel to actually show. Could you post an example in the explorer?
What's the difference between cp.getButtonBar().add(button) and cp.addButton(button)?
Do I have to call cp.getButtonBar().show() or cp.layout(true) after adding a button?
darrellmeyer
05-04-2008, 11:36 PM
Both methods do the same thing. You should not have to do anything than add the buttons for them to show. If you are still having problems, can you post some sample code?
kcaseye
05-05-2008, 03:58 PM
I figured out how to reproduce this issue. Is this a bug, or a problem with my code? I'm trying to add a button after content panel has been rendered.
public void onModuleLoad() {
Viewport viewport = new Viewport();
viewport.setLayout(new FillLayout());
final ContentPanel cp = new ContentPanel();
cp.setHeading("Test Content Panel's button bar");
cp.setLayout(new FlowLayout());
Button b = new Button("Add");
b.addSelectionListener(new SelectionListener() {
public void componentSelected(ComponentEvent ce) {
cp.addButton(new Button("Click"));
}
});
cp.add(b);
viewport.add(cp);
RootPanel.get().add(viewport);
}
kcaseye
05-06-2008, 11:19 AM
Are you not allowed to modify ButtonBar after it has been rendered?
I get this error when I call removeAll on a ButtonBar.
[ERROR] Uncaught exception escaped
java.lang.RuntimeException: component is not a child of this container
at com.extjs.gxt.ui.client.widget.AbstractContainer.remove(AbstractContainer.java:165)
at com.extjs.gxt.ui.client.widget.Container.remove(Container.java:278)
at com.extjs.gxt.ui.client.widget.ButtonBar.remove(ButtonBar.java:200)
at com.extjs.gxt.ui.client.widget.ButtonBar.removeAll(ButtonBar.java:211)
And adding a button to a ButtonBar after it has been rendered does not actually show it. (Although interestingly enough, calling buttonBar.getItemCount() returns the right number.)
gslender
05-06-2008, 05:16 PM
did you try calling layout(true) on the buttonbar after adding - this might then make the remove work?
kcaseye
05-06-2008, 06:09 PM
That was one of the first things I looked for when I noticed nothing was happening. However, there is no layout() function available for the ButtonBar. I've tried calling layout(true) on the ContentPanel and the entire ViewPort that I'm using, with no difference in the results.
gslender
05-06-2008, 06:26 PM
seems like a bug - as a workaround, can you add all the buttons you need and call setVisible on the button you don't want to show etc?
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.