Tree refreshItems dont work

Folks, I have difficulty in tree.refreshItems
I managed to drag the item, but I can not restore it.

This is my xml:

<?xml version='1.0' encoding='iso-8859-1'?>
<tree id="0" >
	<item text="Academico" id="105777" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif" checked="1"></item>
	<item text="Agenda" id="105778" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
	<item text="Barra de Ferramentas" id="105779" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
	<item text="Blogger" id="105016" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif" aCol="red" sCol="red" nocheckbox="1" locked="1">
		<item text="Blog" id="105019" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
		<item text="Comentário" id="105020" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
		<item text="Post" id="105021" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
	</item>
	<item text="Desktop" id="105780" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
	<item text="Diretorio" id="105781" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
	<item text="Earth" id="105782" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
	<item text="Gmail" id="105017" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif" aCol="red" sCol="red" locked="1" nocheckbox="1">
		<item text="Assunto" id="105022" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif" checked="1"></item>
		<item text="Dados Cadastrais" id="105023" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
		<item text="E-mail" id="105024" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
		<item text="IP" id="105025" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
		<item text="Log" id="105026" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
	</item>
	<item text="Google" id="105783" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
	<item text="Google Chrome" id="105784" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
	<item text="Grupos" id="105785" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
	<item text="IGoogle" id="105786" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
	<item text="Imagens" id="105787" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
	<item text="Livros" id="105788" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
	<item text="Maps" id="105789" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
	<item text="Orkut" id="105018" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif" locked="1" aCol="red" sCol="red" nocheckbox="1">
		<item text="Comunidade" id="105027" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
		<item text="Perfil" id="105028" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
		<item text="Post" id="105029" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
		<item text="Scrap" id="105030" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
	</item>
	<item text="Pack" id="105790" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
	<item text="Pesquisa de Blogs" id="105791" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
	<item text="Pesquisa na Web" id="105792" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
	<item text="Picasa" id="105793" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
	<item text="Sketchup" id="105794" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
	<item text="Talk" id="105795" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
	<item text="Youtube" id="105796" im0="icon_success.gif" im1="icon_success.gif" im2="icon_success.gif"  checked="1"></item>
</tree>

This is my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="STYLESHEET" type="text/css" href="../plugin/dhtmlx/dhtmlx/dhtmlxTree/codebase/dhtmlxtree.css">
<script src="../plugin/dhtmlx/dhtmlx/dhtmlxTree/codebase/dhtmlxcommon.js"></script>
<script src="../plugin/dhtmlx/dhtmlx/dhtmlxTree/codebase/dhtmlxtree.js"></script>
<script src="../plugin/dhtmlx/dhtmlx/dhtmlxTree/codebase/ext/dhtmlxtree_li.js"></script>
<script src="../plugin/dhtmlx/dhtmlx/dhtmlxTree/codebase/ext/dhtmlxtree_lf.js"></script>
<script src="../plugin/dhtmlx/dhtmlx/dhtmlxTree/codebase/ext/dhtmlxtree_xw.js"></script>


<title>Tree</title>
</head>
<table>
    <tr>
        <td valign="top">
            <div id="treeboxbox_tree" style="width:250px; height:518px;background-color:#f5f5f5;border :1px solid Silver;">
                <div style="display:none; width:100%; height:100%; background-color:black;" id="b_1">
                    <table width="100%" height="100%" align="center">
                        <tr align="center" valign="middle">
                            <td align="center" valign="middle">
                                <h1 style="color:red; text-align:center; vertical-align:middle;">Loading</h1>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </td>
        <td style="padding-left:25px" valign="top">
            <div id="treeboxbox_tree2" style="width:250px; height:518px;background-color:#f5f5f5;border :1px solid Silver;overflow:hidden;"/>
        </td>
        <td style="padding-left:25" valign="top">
        <a href="javascript:void(0)" onClick="tree.refreshItems('710583','tree_radio.xml')">Restore</a><br><br>
        </td>
    </tr>
</table>
<br>
<script>
tree = new dhtmlXTreeObject("treeboxbox_tree", "100%", "100%", 0);
tree.setSkin('dhx_skyblue');
tree.setImagePath("../plugin/dhtmlx/dhtmlx/dhtmlxTree/codebase/imgs/");
tree.enableCheckBoxes(1);
tree.enableDragAndDrop(1);
tree.enableMultiselection(0,0);
tree.enableHighlighting(false|false); 
tree.enableSmartXMLParsing(1);
tree.setOnLoadingStart(func_a);
tree.setOnLoadingEnd(func_b);
tree.enableThreeStateCheckboxes(true);
tree.loadXML("tree_radio.xml");

tree2 = new dhtmlXTreeObject("treeboxbox_tree2", "100%", "100%", 0);
tree2.setSkin('dhx_skyblue');
tree2.setImagePath("../plugin/dhtmlx/dhtmlx/dhtmlxTree/codebase/imgs/");
tree2.enableCheckBoxes(0);
tree2.enableDragAndDrop(1);
tree2.setDragBehavior("sibling");


function func_a() {
    document.getElementById("b_1").style.display = "";
}
function func_b() {
    document.getElementById("b_1").style.display = "none";
}
</script>
<body>

</body>
</html>

And this is the error screens:






Could anyone help me?

What should be done to reproduce the problem ?

You calls tree.refreshItems(‘710583’,‘tree_radio.xml’), but there isn’t the item with id = 710583

Hi Alexandra.

When I drag the item to the tree2 it automatically destroys the tree and builds on the tree2. Because it shows the error.
I need a solution dhtmlxTree I can drag the item to tree2 and then restores it in the tree in the same position. I found that this method could but I’m open to new ideas.
Link:
http://ww1.dlbca.com.br/4Data/teste/tree.asp

Hi,

there is mercy drag functionality that allows to copy node (not to delete item after it dropped). In this case you don’t need to refresh the tree:

tree.enableMercyDrag(true);

The reason for the refreshing error is Smart Xml Parsing mode. An item is deleted from the tree, but in this mode tree checks nodes in the xml. And as the item exists in the xml, non-unique error occurs when this item is added.

Try not to use Smart Xml Parsing and you may use smartRefreshBranch(0,‘tree_radio.xml’); to refresh the whole tree. But in my opinion mercy drag is more efficient solution.

Hi,

It was exactly what I did.
Below the xml and code:

<?xml version='1.0' encoding='iso-8859-1'?>
<tree id="0" >
	<item text="Academico" id="105777" ></item>
	<item text="Agenda" id="105778"></item>
	<item text="Barra de Ferramentas" id="105779"></item>
	<item text="Blogger" id="105016" locked="1" aCol="red" sCol="red" open="1">
		<item text="Blog" id="105019"></item>
		<item text="Comentário" id="105020"></item>
		<item text="Post" id="105021"></item>
	</item>
	<item text="Desktop" id="105780"></item>
	<item text="Diretorio" id="105781"></item>
	<item text="Earth" id="105782"></item>
	<item text="Gmail" id="105017" locked="1" aCol="red" sCol="red" open="1">
		<item text="Assunto" id="105022" ></item>
		<item text="Dados Cadastrais" id="105023"></item>
		<item text="E-mail" id="105024"></item>
		<item text="IP" id="105025"></item>
		<item text="Log" id="105026"></item>
	</item>
	<item text="Google" id="105783"></item>
	<item text="Google Chrome" id="105784"></item>
	<item text="Grupos" id="105785"></item>
	<item text="IGoogle" id="105786"></item>
	<item text="Imagens" id="105787"></item>
	<item text="Livros" id="105788"></item>
	<item text="Maps" id="105789"></item>
	<item text="Orkut" id="105018" locked="1" aCol="red" sCol="red" open="1">
		<item text="Comunidade" id="105027"></item>
		<item text="Perfil" id="105028"></item>
		<item text="Post" id="105029"></item>
		<item text="Scrap" id="105030"></item>
	</item>
	<item text="Pack" id="105790"></item>
	<item text="Pesquisa de Blogs" id="105791"></item>
	<item text="Pesquisa na Web" id="105792"></item>
	<item text="Picasa" id="105793"></item>
	<item text="Sketchup" id="105794"></item>
	<item text="Talk" id="105795"></item>
	<item text="Youtube" id="105796"></item>
</tree>
<title>Tree</title>
</head>
<table>
    <tr>
        <td valign="top">
            <div id="treeboxbox_tree" style="width:250px; height:518px;background-color:#f5f5f5;border :1px solid Silver;">
                <div style="display:none; width:100%; height:100%; background-color:black;" id="b_1">
                    <table width="100%" height="100%" align="center">
                        <tr align="center" valign="middle">
                            <td align="center" valign="middle">
                                <h1 style="color:red; text-align:center; vertical-align:middle;">Loading</h1>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </td>
        <td style="padding-left:25px" valign="top">
            <div id="treeboxbox_tree2" style="width:250px; height:518px;background-color:#f5f5f5;border :1px solid Silver;overflow:hidden;"/>
        </td>
        <td style="padding-left:25" valign="top">
        <br>
        <img src="../images/saveicon.gif" name="bt_salvarProduto" id="bt_salvarProduto" onclick="fn_salvarProdutos();" style="cursor:pointer;" />
        <img src="../images/reload.png"   name="bt_alterarProduto" id="bt_alterarProduto" onclick="fn_alterarProdutos();" style="cursor:pointer; display:none;" />
        
        

        </td>
    </tr>
</table>
<br>
<script>

tree = new dhtmlXTreeObject("treeboxbox_tree", "100%", "100%", 0);
tree.setSkin('dhx_skyblue');
tree.setImagePath("../plugin/dhtmlx/dhtmlx/dhtmlxTree/codebase/imgs/csh_Lockers/");
tree.enableDragAndDrop(1);
tree.enableMercyDrag(true); 
tree.setDragBehavior("sibling");
tree.setLockedIcons("lock.GIF", "lock.GIF", "lock.GIF");
tree.setItemImage2('leaf.gif','leaf.gif','leaf.gif');
tree.setOnLoadingStart(func_a);
tree.setOnLoadingEnd(func_b);

tree.attachEvent("onDrag", function(sId,tId,id,sObject,tObject){
		document.getElementById('validadorTree1').value = sId;
	return true;
 });
tree.attachEvent("onDrop", function(sId,tId,id,sObject,tObject){
		document.getElementById('validadorTree2').value = sId;
		tree.refreshItems(document.getElementById('validadorTree1').value, "http://ww1.dlbca.com.br/4Data/tree/exemplo.asp?rs="+Math.random());
		tree.lockItem(document.getElementById('validadorTree1').value,false);
		tree2.deleteItem(document.getElementById('validadorTree1').value,true);
		tree.deleteItem(document.getElementById('validadorTree2').value,true);
	if(tObject==sObject){
		return false;
	}else{
		return true;
	}
 });
tree.loadXML("http://ww1.dlbca.com.br/4Data/tree/exemplo.asp?rs="+Math.random());




tree2 = new dhtmlXTreeObject("treeboxbox_tree2", "100%", "100%", 0);
tree2.setSkin('dhx_skyblue');
tree2.setImagePath("../plugin/dhtmlx/dhtmlx/dhtmlxTree/codebase/imgs/csh_Lockers/");
tree2.enableDragAndDrop(1);
tree2.setDragBehavior("sibling");
tree2.attachEvent("onDrop", function(sId,tId,id,sObject,tObject){
	if(tObject==sObject){
		return false;
	}else{
		tObject.lockItem(tId,false);
		sObject.lockItem(sId,true);
		return true;
	}
 });
 
 

function func_a() {
    document.getElementById("b_1").style.display = "";
}
function func_b() {
    document.getElementById("b_1").style.display = "none";
}



function fn_salvarProdutos(){
document.getElementById('setValuesProdutos').value = tree2.getAllLeafs();
tree.lockTree(true);
tree2.lockTree(true);
document.getElementById('bt_alterarProduto').style.display="block";
document.getElementById('bt_salvarProduto').style.display="none";
}
function fn_alterarProdutos(){
tree.lockTree(false);
tree2.lockTree(false);
document.getElementById('setValuesProdutos').value = "";
document.getElementById('bt_alterarProduto').style.display="none";
document.getElementById('bt_salvarProduto').style.display="block";
}

</script>
<input type="hidden" name="validadorTree1" id="validadorTree1" value="" />
<input type="hidden" name="validadorTree2" id="validadorTree2" value="" />
<input type="text" name="setValuesProdutos" id="setValuesProdutos" value="" size="100" />

Result:
http://ww1.dlbca.com.br/4Data/teste/tree2.asp

Thank you Alexandra for the willingness to help,
FelipeTv.

Hi,

it seems that now evethings works correctly. Am I right ?

You are completely right.
Tks a lot.