PDA

View Full Version : GXT: How can i add/remove forms dynamically to a panel?



triton
15 May 2009, 7:31 PM
subj GXT:
level: just started on GXT

can anyone share a code snippet or direct me to some discussions as to how i can add/remove forms dynamically to a central panel, based on some event.
The forms need to be created dynamically at run time based on a event. The GXT documentation does not clearly mention about this, also i couldn't get much help from the examples.

By using <div id="foo"></div> in the abc.html i am able to get a reference to that using RootPanel.get("foo") and add a form dynamically to that. However i feel this is not a good design and very restrictive.

I tried the following options too, but they do not work. I am probably missing out on some concepts... any help is appreciated.

approach 1.

ContentPanel cp ... //available as a reference (design time)

addForm(....) {
FormPanel fp = new Formpanel();
......
cp.add(fp);
}


approach 2.

ContentPanel cp = new ContentPanel(); //design time
cp.setId("xyz");
.....

addForm() {
FormPanel fp = new Formpanel();
......
RootPanel.get("xyz").add(fp);
}


cheers,
-triton-

Jose_R
25 Jun 2010, 8:49 AM
Hi Could anyone provide an example about this ?
I am trying to also generate dynamic forms and add them to a panel, however even if I am able to generate the forms I am not able show them on screen. Which method do I have to use in the content panel for it to be refreshed ?

I have tried repaint() and also raise the render event for the content panel with Events.Render but no luck so far.

Is it possible to refresh the content of a panel in case you are not using stores ?

sven
25 Jun 2010, 8:54 AM
Is it possible to refresh the content of a panel in case you are not using stores ?
How is a panel linked to a store?

Simple call layout on the container you are modifying

Jose_R
25 Jun 2010, 9:08 AM
Sorry if I didn't explain myself correctly. When I mentioned stores, I meant a stored connected to a grid, and the grid associated to the content panel.
In any case executing layout did the trick and the content of the panel was refreshed.

Thanks a lot for your quick response.