0

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 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);
}
StarPinkER
  • 14,081
  • 7
  • 55
  • 81

2 Answers2

0

IMHO you should add <div id="xyz"></div> in your html file at Approach 2. Your form panel will be rendered directo to this div. So don't forget to specify its width and height btw.

Artem
  • 603
  • 1
  • 9
  • 21
0

Actually, add a layout() method will solve this problem.

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

addForm(....) {
    FormPanel fp = new Formpanel();
    ......
    cp.add(fp);
    **cp.layout();**
}
StarPinkER
  • 14,081
  • 7
  • 55
  • 81