dhtmlxgrid: getting an xml string of grid data

Posted by user823527 on Stack Overflow See other posts from Stack Overflow or by user823527
Published on 2011-11-22T17:31:36Z Indexed on 2011/11/22 17:50 UTC
Read the original article Hit count: 528

Filed under:
|
|

The dhtmlxgrid documentation is saying that I should be able to get a string with the grid data with the serialize feature.

    mygrid.setSerializationLevel(true,true);
    var myXmlStr = mygrid.serialize();

I'd like to use that feature to get the updated grid data. But I don't get the xml string. Is that feature not available in the open source version?

If I could get a csv string, that would also be OK. But I don't get that either.

    var gridcsv=mygrid.serializeToCSV();
    document.getElementById("mytextareax").value = gridcsv;

The html information for the grid is:

<a href="#" onclick="savegrid();">Save Grid</a>
<textarea id="mytextareax"><rows><row id='r1'><cell>index ... </rows></textarea>
<div id="mytextarea" style="width:400px; height: 400px;"> </div>
<div id="gridbox" style="width:600px; height:270px; background-color:white;"></div>
<a href='#alfa' onClick="ser()">Reload grid with another structure</a>
<br>

The script for creating the grid is:

<script>
    mygrid = new dhtmlXGridObject('gridbox');
    mygrid.setImagePath("../../codebase/imgs/");
    mygrid.loadXML("../common/grid500.xml");

    function ser(){
        mygrid.clearAll(true);
        mygrid.loadXML("../common/gridH3.xml");
    }

    function savegrid(){
        alert('save grid');
        mygrid.setSerializationLevel(true,true);
        var myXmlStr = mygrid.serialize();
        /* document.getElementById("mytextarea").innerHTML  = myXmlStr; */
        document.getElementById("mytextareax").value = myXmlStr;
        alert(myXmlStr);        
    }
</script>

Is there any way to get the data out of the dhtmlx grid to be able to create my own xml file from it?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about grid