Completely reload a form from xml

Hi
I have a quick question. Is there a way by which we can recreate the form like we do with grid.

i.e;
In grid we have

mygrid.clearAndLoad(‘structureanddata.xml’);
Which recreates the grid from scratch.

I tried
myfrom.clear();
myform.clearAndLoad(‘formxml.xml’);
but the results are not what I wanted. The form just duplicated itself.

Please help.

Hi
Where is your form placed/attached?

There are 2 forms:
Both are dynamically created from the xml that is received from the server.

One form is attached to the dhtmlx layout on the page and is a search form.
The other one is attached to the dhtmlx layout in a dhtmlx window and is the form used to add/edit values in a dhtmlx grid(based on selection).

Now when I add a new item through this form, The search form combos as well as this edit form should reflect the new values(in their options).
This is where I face the problem. Your tech analyst suggested to use form.clear() but when I call a form.loadStruct() it does not clear the form like the above function in the grid. It adds the xml to the existing form thereby doubling the form. I tried form.unload() but then form.loadStruct() does not work anymore(the form disappears).
Do I have to layout.attachform() again and load the structure ?
Basically I want to avoid a page refresh as that takes quite a while…

When I say add the new item upon editing with the dhtmlxwindow form, I mean if the value entered is not in the list of options in a combo that should get added to the list otherwise the combo should be as it is. All combos are dynamically generated in the form and have no static names.

Hi

how about to enclose all items into a single block…

<?xml version="1.0"?> <items> <item type="block" name="myBlock" width="auto" blockOffset="0"> <!-- your form here --> </item> </items>

… and then simply remove this block before loading new struct?

myForm.removeItem("myBlock");

width=“auto” will adjust block to nested items and blockOffset=“0” will remove default 20px left-side padding

If nested, the whole form xml will be loaded again, then there’s another tag and the tags will accumulate if removal happens again and again. Is it ok?