DHTMLX Docs & Samples Explorer

TreeGrid serialization

Serialization for dhtmlxTreeGrid gives you actual state of the content in xml format.
Math formulas can be serialized as formulas or as values.

 
Delete selected rows
addRowBefore selected rows
addRowAfter selected rows
Source
    
<link rel="STYLESHEET" type="text/css" href="../../../dhtmlxGrid/codebase/dhtmlxgrid.css">
<link rel="stylesheet" type="text/css" href="../../../dhtmlxGrid/codebase/skins/dhtmlxgrid_dhx_skyblue.css">
<script  src="../../../dhtmlxGrid/codebase/dhtmlxcommon.js"></script>
<script  src="../../../dhtmlxGrid/codebase/dhtmlxgrid.js"></script>
<script  src="../../../dhtmlxGrid/codebase/dhtmlxgridcell.js"></script>
<script  src="../../codebase/dhtmlxtreegrid.js"></script>
<script  src="../../../dhtmlxGrid/codebase/ext/dhtmlxgrid_math.js"></script>
<table width="835">
    <tr>
        <td width="600px">
            <div id="gridbox" width="100%" height="250px" style="background-color:white;"></div>
        </td>
        <td valign="top">
            <textarea style='width:300px; height:230px;'></textarea><div><a href="#" onclick="this.parentNode.previousSibling.value=mygrid.serialize()">Serialize TreeGrid</a></div>
        </td>
    </tr>
    <tr>
        <td>&nbsp;</td>
    </tr>
</table>
 
<script>
mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath("../../../dhtmlxGrid/codebase/imgs/icons_books/");
mygrid.setHeader("Title,Price,Quantity,Total");
mygrid.setInitWidths("250,100,80,100");
mygrid.setColAlign("left,right,right,right");
mygrid.setColTypes("tree,price,ed[=sum],price[=sum]");
mygrid.setColSorting("str,int,int,int");
mygrid.setMathRound(2);
mygrid.init();
mygrid.setSkin("dhx_skyblue");
mygrid.loadXML("../common/treegrid_sample_06_serialization.xml");
</script> <div><a href="#" onclick="mygrid.deleteSelectedItem()">Delete selected rows</a></div> <div><a href="#" onclick="mygrid.addRowBefore((new Date()).valueOf(),['new row','text','text',1,0],mygrid.getSelectedId())">addRowBefore selected rows</a></div> <div><a href="#" onclick="mygrid.addRowAfter((new Date()).valueOf(),['new row','text','text',1,0],mygrid.getSelectedId())">addRowAfter selected rows</a></div>