TreeGrid basic operations
Basic operations - add, delete rows in TreeGrid
|
</> Source
<!DOCTYPE html>
<html>
<head>
<title>TreeGrid basic operations</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<link rel="stylesheet" type="text/css" href="../../../codebase/fonts/font_roboto/roboto.css"/>
<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlx.css"/>
<script src="../../../codebase/dhtmlx.js"></script>
<script>
var myTreeGrid;
function doOnLoad() {
myTreeGrid = new dhtmlXGridObject('gridbox');
myTreeGrid.setImagePath("../../../codebase/imgs/");
myTreeGrid.setHeader("Tree,Plain Text,Long Text,Color,Checkbox");
myTreeGrid.setInitWidths("150,100,100,100,90");
myTreeGrid.setColAlign("left,left,left,center,center");
myTreeGrid.setColTypes("tree,ed,txt,ch,ch");
myTreeGrid.setColSorting("str,str,str,na,str");
myTreeGrid.enableAutoHeigth(true);
myTreeGrid.init();
myTreeGrid.load("../common/test_list_1.xml");
}
</script>
</head>
<body onload="doOnLoad();">
<h1>TreeGrid basic operations</h1>
<p>Basic operations - add, delete rows in TreeGrid</p>
<table width="550">
<tr>
<td>
<div id="gridbox" width="100%" height="250px" style="background-color:white;"></div>
</td>
</tr>
<tr>
<td>
<div id="gridtbl1" width="100%" height="200px" style="background-color:white;"></div><br><br>
<div><a href="#" onclick="myTreeGrid.addRow((new Date()).valueOf(),['new row','text','text',1,0],0)">Add new row</a></div>
<div><a href="#" onclick="var z=myTreeGrid.getRowId(this.nextSibling.value); if (z) myTreeGrid.addRow((new Date()).valueOf(),['new row','text','text',1,1],0,z)">Add new row at child of node at position</a><input></div>
<div><a href="#" onclick="var z=myTreeGrid.getSelectedId(); if (z) myTreeGrid.addRow((new Date()).valueOf(),['new row','text','text',1,1],0,z)">Add new row as child of selected</a></div>
<div> </div>
<div><a href="#" onclick="var z=myTreeGrid.getRowId(this.nextSibling.value); if (z) myTreeGrid.deleteRow(z)">Delete row at position</a><input></div>
<div><a href="#" onclick="myTreeGrid.deleteSelectedItem()">Delete selected rows</a></div>
<div><a href="#" onclick="myTreeGrid.addRowBefore((new Date()).valueOf(),['new row','text','text',1,0],myTreeGrid.getSelectedId())">addRowBefore selected rows</a></div>
<div><a href="#" onclick="myTreeGrid.addRowAfter((new Date()).valueOf(),['new row','text','text',1,0],myTreeGrid.getSelectedId())">addRowAfter selected rows</a></div>
</td>
</tr>
</table>
<br>
<div><a href="#" onclick="alert(myTreeGrid.getRowIndex(myTreeGrid.getSelectedId()))">Index of selected</a></div>
<div><a href="#" onclick="myTreeGrid.expandAll()">expandAll</a></div>
<div><a href="#" onclick="myTreeGrid.collapseAll()">collapseAll</a></div>
</body>
</html>
Documentation
Check documentation to learn how to use the components and easily implement them in your applications.