Categories | Question details Back To List | ||
dhtmlx - add & update xml (no db being used). What options do i have? dhtmlxgrid - add & update xml (no need for db). I'm building a website in flash and it reads data from a xml file. For now i add the data manualy in a xml file. So i was looking for a better way to input data in xml so i found dhtmlx through google. Espescially because the secretary needs to input the data so i want to use the dhtmlxgrid to add and update the xml file. I've been able to load an xml file into a grid and the only thing left to do, is saving the modifications back to xml file. So just to be clear: i only want to update the xml file on the server. I dont want to use a DB if I dont need to. From what i've read there are a couple of options: 1)dhtmlXDataProcessor which is only available in Pro: Can this be used to save the xml or is it only to save the data in a DB 2)serialization which also only available in Pro So does this mean i need to buy the pro version to be able to save the changes i made in a grid? Do you get an example on how to update an xml. And if so how much does it cost cause i have absolutly no idea about how much this cost. You are free to contact me through my emailaddress. Thanks. Gosa Answer posted by Support on Jan 31, 2008 06:40 >>So does this mean i need to buy the pro version to be able to save the changes i made in a grid? The grid uses XML only as datasource , so all updates of values in grid not reflected in XML directly. You can achieve similar to serialization by next code var xml=[]; mygrid.forEachRow(function(id){ var cxml=[]; mygrid.forEachCell(id,function(c){ cxml.push("<cell>"+c.getValue+"</cell>"); } xml.push("<row>"+cxml.join()+"</row>") }); xml=xml.join(""); Answer posted by Gosa on Feb 01, 2008 02:07 Hi, Thanks for the response. I tried the code you gave. I've put it in a function and just used a simple a href link that calls that function. I've traced the c.getValue to see what is being pushed in the array but i get something weird unless im missing something. mygrid.forEachCell(id,function(c){ I get in the alertbox: c: function(){if((this.cell.firstChild)&&((this.cell.atag)&&(this.firstChild.tagName==this.cell.atag))) Am i doing something wrong cause when i trace the xml var in the end i get a bunch of code instead of the xml tree? Thanks. Gosa
Answer posted by Support on Feb 01, 2008 04:05 Was a my typo, sorry for inconvenience, I missed brackets after getValue ( this not a property , but method ) mygrid.forEachCell(id,function(c){ cxml.push("<cell>"+c.getValue()+"</cell>"); } Answer posted by Gosa on Feb 01, 2008 08:09 Thanks that was it. With the () i was able to see the content of the cells. I added in the beginning: xml.push("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); xml.push("<rows>"); And changed the code for row to include the id(see code below), cause i'm trying to replace(recreate) the xml file that was loaded from with the new content. xml.push("<row id=\"" +id + "\"/>"+cxml.join()+"</row>"); So i think now I have an array with the whole grid with the updated information. Since Java can't write xml files on the server I need to pass this array to php and let php write the xml file right? How do I send this array to php with javascipt? In php i think will need something like this: <?php $filename = "data.xml"; ... $fp = fopen($filename, "w"); fwrite($fp, $var_xml); fclose($fp); ?> Any help with the php is always welcome. Thanks. Greetz, Gosa Answer posted by Support on Feb 04, 2008 07:17 >>How do I send this array to php with javascipt? You can use native HTML ways ( for example hidden field inside form ) or use custom or built-in AJAX call (new dtmlXMLLoaderObject(function(){ //code will be executed after data sending and response loading },window,true,true).loadXML("some.php",true,"data="+encodeURIComponent (xml.join())) In php you can take it as $_POST['data'] |