I trying to build a tree view with DataConnector and DataProcessor to write the changes back. But I see that when the tree first renders all elements that are drawn on the screen are sent back through DataProcessor as an ‘inserted’ traction. This causes all the entires in the db to be duplicated. New child entries that I add on the GUI manually also come across the DataProcessor as ‘inserted’. How do I differentiate them?
<link rel="stylesheet" type="text/css" href="../api/dhtmlxMenu/codebase/skins/dhtmlxmenu_dhx_skyblue.css">
<link rel="STYLESHEET" type="text/css" href="../api/dhtmlxTree/codebase/dhtmlxtree.css">
<script src="../api/dhtmlxLayout/codebase/dhtmlxcommon.js" type="text/javascript"></script>
<script src="../api/dhtmlxTree/codebase/dhtmlxtree.js"></script>
<script src="../api/dhtmlxMenu/codebase/dhtmlxmenu.js"></script>
<script src="../api/dhtmlxMenu/codebase/ext/dhtmlxmenu_ext.js"></script>
<script src="../api/dhtmlxTree/codebase/ext/dhtmlxtree_ed.js"></script>
<script src="../api/dhtmlxDataProcessor/codebase/dhtmlxdataprocessor.js"></script>
<script src="../api/dhtmlxDataProcessor/codebase/dhtmlxdataprocessor_debug.js"></script>
<script src="../api/dhtmlxTree/codebase/ext/dhtmlxtree_srnd.js"></script>
<table>
<tr>
<td>
<div id="treeboxbox_tree" style="width:260px; height:260px;background-color:#f5f5f5;border :1px solid Silver;"/>
</td>
<td valign="top">
</td>
</tr>
<tr>
<td></td>
</tr>
</table>
<div id="aler"></div>
<br>
<script>
menu = new dhtmlXMenuObject();
menu.setIconsPath("../api/dhtmlxTree/samples/common/images/");
menu.renderAsContextMenu();
menu.attachEvent( "onClick", onButtonClick );
menu.loadXML("dyn_context.xml");
tree = new dhtmlXTreeObject( "treeboxbox_tree", "100%", "100%", 0 );
tree.setSkin('dhx_skyblue');
tree.setImagePath("../api/dhtmlxTree/codebase/imgs/csh_bluebooks/");
tree.enableDragAndDrop(true);
tree.enableContextMenu(menu);
tree.enableSmartRendering(true);
tree.kidsXmlFile = 'bulkupd_connector.php';
tree.loadXML('bulkupd_connector.php');
tree.attachEvent("onBeforeContextMenu", onShowMenu);
myDataProcessor = new dataProcessor("xupdate.php");
myDataProcessor.init(tree);
function onButtonClick(menuitemId)
{
switch (menuitemId) {
case "add":
tree.insertNewItem( tree.getSelectedItemId(),tree.getSelectedItemId(),'new item 123',null,'folderClosed.gif','folderClosed.gif','folderOpen.gif','SELECT');
break;
case "delete":
;
// window.setTimeout("tree.deleteRow(" + rId + ");", 200);
break;
}
}
function onShowMenu(rowId, celInd, grid) {
var arr = ["inc", "dec", "link", "edit", "set_avail", "set_unavail", "del_best", "add_best"];
for (var i = 0; i < arr.length; i++) {
menu.hideItem(arr[i]);
}
switch (celInd) {
case 0:
;
menu.showItem("inc");
menu.showItem("dec");
break;
case 1:
;
menu.showItem("link");
break;
case 2:
;
menu.showItem("link");
break;
case 3:
;
menu.showItem("edit");
break;
case 4:
;
menu.showItem("set_avail");
menu.showItem("set_unavail");
break;
case 6:
;
menu.showItem("del_best");
menu.showItem("add_best");
break;
}
return true;
}
</script>
<br><br>