dhtmlx - add & update xml (no db being used). What options d

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





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©{
       cxml.push(""+c.getValue+"");
    }
    xml.push(""+cxml.join()+"")
});

xml=xml.join("");


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.
When i execute the function nothing seems to happen.



I’ve traced the c.getValue to see what is being pushed in the array but i get something weird unless im missing something.
When i use the folowing code:



mygrid.forEachCell(id,function©{
     alert(“c: " + c.getValue);
     cxml.push(”"+c.getValue+"");
     alert(“cxml: " + cxml);
    })



I get in the alertbox:



c: function(){if((this.cell.firstChild)&&((this.cell.atag)&&(this.firstChild.tagName==this.cell.atag)))
return this.cell.firstChild.value;if(this.cell._clearCell)return”";return this cell.innerHTML.toString()._dhx_trim()}



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



 

Was a my typo, sorry for inconvenience, I missed brackets after getValue ( this not a property , but method )


    mygrid.forEachCell(id,function©{
       cxml.push(""+c.getValue()+"");
    }

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("");

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()+"");

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

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’]