Form Container From XML

Hi.
Im creating a form loading a xml file. I need to create a container inside the form.
How can i create the container in the xml file to pass to the form?
Thanks.

hi

xml:

<item type="container" name="test"/>

js:

myForm.loadStruct(url, function(){ var t = myForm.getContainer("test"); }); var p = myForm.getContainer("test");

due form loads data in async mode, you need to use callback function to get container, i.e. form is 100% loaded and items parsed, “var t” - ok, “var p” - do not use (common mistake, just for info)

Thanks Andrei. I im loading the form in sync mode.
Do you have an example of a xml form with container? I cant found anyone.

Hi

unfortunately we do not have ready samples with xml+container.
see codelines you need in my prev post

Ok, one question…
I added the container in the form xml.
Have i treat the container element like a grid element to complete the xml attributes?
Thanks

var t = myForm.getContainer(“test”);
this will give you div html object, you can can operate with “t”

i dont understand or my english is worst and i cant explain what im trying to do.
I want to load the container from an xml, not from a Js.

I is an example of what im trying to do.

<?xml version="1.0"?>

- - - - - familias add_object - familias - - - Id familia Descripción - % Usuarios - 1 Administrador - 2 Área 1 - 3 Área 2 - 4 Área 3 - 5 Área 4 - 6 Área 5

well…

container is DIV object on a page which “integrated” into form and do not have more functionality. form can give you link to this object and then yuo able to use it for your needs, for exampl to init grid, insert image, etc.

to init it you need to give command to form like “init container”. this can be done by using json or xml. in your case - xml should contain (you also can specify other params like inputWidth, inputHeight…, list of params here: docs.dhtmlx.com/doku.php?id=dhtm … _container also make sure file ext/dhtmlxform_item_container.js included on a page)

after form loaded and container inited - you need to get link to div object and procced with other code, for example init grid:
var t = myForm.getContainer(name);
var grid = new dhtmlXGridObject(t);

here is a demo with grid: dhtmlx.com/docs/products/dht … _grid.html
the only difference is init - in demo it json, you need xml. when you load xml using loadStruct() you need to use callback to get container, because form loads data using async mode.

in you code:
… will not work, form will not parse , it only create container, then you able to load xml into your grid manualy:
var t = myForm.getContainer(name);
var grid = new dhtmlXGridObject(t);
grid.loadXML(url); // here will …and other grid conf and rows data

Thanks Andrei. It works.
The answer was very clear and usefull.
Thanks again-

Hi guys,

In my code don’t function. Can you help me?

The form function normaly but the grid don’t show it.

See the code in the files. Alone all function correctily:
/----------------------------------------------------------------------------------------------------------------
form.xml:

<?xml version="1.0" encoding="UTF-8"?> /----------------------------------------------------------------------------------------------------------------

mygrid.xml

Colun 1 Colun 2 Colun 3 px 12890.00003460.0000 22890.00003460.0000 /----------------------------------------------------------------------------------------------------------------

script.js

function doOnLoadFormVenda() {
myForm = new dhtmlXForm(“my_form”);
myForm.loadStruct(“form.xml”);
myForm.adjustParentSize();
var container=myForm.getContainer(“mygrid”);
mygrid = new dhtmlXGridObject(container);
mygrid.setImagePath(“codebase/imgs/”);
mygrid.setSkin(“dhx_skyblue”);
mygrid.loadXML(“mygrid.xml”);
}

Hi, Dimitri Ardaz
Do you load your page “under” any server? You need to run it to render XML grid.

hi

try this

myForm.loadStruct(“form.xml”, function(){
var container=myForm.getContainer(“mygrid”);
mygrid = new dhtmlXGridObject(container);
});

as I said in prev post - form’s xml loaded via async request, so when you try to init grid - container not yet loaded