Loading data to the form on the client side

I have on my page a JS variable which contains data in xml format

<data xmlns="">  <Id>3</Id>  <NazovProjektu>nazov</NazovProjektu>  <Oz> der4</Oz>  <PopisProjektu>cccc</PopisProjektu>  <Poznamka>cccccc</Poznamka>  <DatumVytvorenia>2. 12. 2009</DatumVytvorenia> </data>"

I’d like to load this data into an existing form.

I tried to use the load function like

form.load(data);

but this fired an ajax request. Is there any way to load the data on the client side ?

You can use loadStructString() method. Please check example here dhtmlx.com/docs/products/dht … m_xml.html

I tried loadStructString but its not working.I thought that loadStructString is for loading the form definition. But in my case the form has been already created. But its empty. Now I have on my site a variable where I have just data to display

<data xmlns=""> <Id>3</Id> <NazovProjektu>nazov</NazovProjektu> <Oz> der4</Oz> <Poznamka>cccccc</Poznamka> <DatumVytvorenia>2. 12. 2009</DatumVytvorenia> </data>

I’d like to load the into the form.

I tried loadStructString but I got an exception

Please see attached pic.


hey support where’re you ?

Hello,

unfortunately there was not the public method to load the whole data set on the client side.

You may use setItemValue to set a value for a certain input:

form.setItemValue(bind,value);

I’ve attached the modified dhtmlxform.js that contains “parse” method. It allows to set all values at once:

form.parse({ “bind1” : “value1”, “bind2” : “value2”, … , “bindN” : “valueN”});
dhtmlxform.zip (13.8 KB)

I have tried to use “parse” method from attached file, but it doesn’t work.
I have a form initialized from XML file.
When I try to fill form after onXLE event with “parse” method fields are left empty.
When I try to use setItemValue - everything works fine.
You can check this issue on my test form at
bell.ru/dhtmlx/formtest.html
“Parse” method called from “onload” event and “setItemValue” called after clicking on a button
Thanks in advance