Hi,
I am Dhtmlxtree for drag and drop functionality in between two trees. It is working fine to drag and drop from one tree to another. But the problem once I dropped the node, it is always travelling with the mouse curser pointer until i click the mouse somewhere in the page. When i see the firebug it is says “tree is not defined
[Break on this error] if (Nodes[i]==zParent){flag=Nodes[i];No…t.treeNod.lWin!=targetObject.lWin);else\n” .But i have included dhtmlxtree.js file as well. what is the problem? please help me.
Thanks,
Vel
Hello,
please provide the code for tree initialization to re-create the issue.
var ajaxRequest=GetXmlHttpObject();
var customerID=document.getElementById(‘customerID’).value;
menu = new dhtmlXMenuObject(null,“standard”);
menu.setImagePath(“themes/General/css/dhtmlxMenu/imgs/”);
menu.setIconsPath(“themes/General/css/dhtmlxTree/images/”);
menu.renderAsContextMenu();
menu.setOpenMode(“web”);
menu.attachEvent(“onClick”,onButtonClick);
menu.loadXML(“xmlfile/holidayActions.xml");
function onButtonClick(menuitemId,type)
{
var id = HTemplatetree.contextID;
//alert(id);
//alert(id.indexOf(“H”));
//alert(menuitemId);
//return false;
// alert(id + " menuid =" + menuitemId + " type= " +type);
if(menuitemId==‘add’)
{
var autoid=document.getElementById(‘nextTemplateID’).value;
var id=“HT-”+autoid;
var newname=“New Holiday Template” +autoid;
HTemplatetree.insertNewNext(HTemplatetree.getSelectedItemId()||0,id,newname,0,0,0,0,"");
document.getElementById(‘nextTemplateID’).value=parseInt(autoid)+1;
}
if(menuitemId==‘edit’)
{
//alert(‘edit’+id);
// alert(menuitemId);
// alert(id.indexOf(‘HT-’));
if(id.indexOf(‘HT-’) > -1)
{
HTemplatetree.enableItemEditor(true);
document.getElementById(‘forEditor’).value=id;
}
if(id.indexOf(‘H-’) > -1)
{
HTemplatetree.enableItemEditor(false);
}
}
if(menuitemId==‘delete’)
{
if( id.indexOf(“HT-”) > -1)
{
if(confirm(“Do you want to remove the Holiday Template?”)==true)
{
HTemplatetree.deleteItem(id);
}
}
if( id.indexOf(“H-”) > -1)
{
if(confirm(“Do you want to remove the assigned Holiday?”)==true)
{
HTemplatetree.deleteItem(id);
}
}
}
}
HTemplatetree=new dhtmlXTreeObject(“treeboxbox_tree1”,“100%”,“100%”,0);
HTemplatetree.setImagePath(“themes/General/css/imgs/csh_bluefolders/”);
HTemplatetree.enableContextMenu(menu);
HTemplatetree.enableMultiselection(true);
HTemplatetree.enableMercyDrag(false);
HTemplatetree.enableSmartXMLParsing(true);
HTemplatetree.setOnEditHandler(m_func);
function m_func(state,id,tree,value)
{
// alert(“state=>”+state);
// alert(“ID=>”+id);
// alert(“Tree==>”+tree);
// alert(“value==>”+value);
if(id.indexOf(‘HT-’) > -1)
{
if(value=="")
{
alert(‘Template Name should not be empty’);
return false;
}
return true;
}
if(id.indexOf(‘H-’) > -1)
{
HTemplatetree.enableItemEditor(false);
return false;
}
}
HTemplatetree.attachEvent(“onRightClick”,function(itemId)
{
//alert(itemId);
HTemplatetree.focusItem(itemId);
HTemplatetree.selectItem(itemId);
});
HTemplatetree.attachEvent(“onBeforeContextMenu”,function(itemId){
// alert(‘vel’+itemId.indexOf(‘HT-’));
if(itemId.indexOf(‘HT-’) > -1)
{
// alert(‘HTemplate’);
menu.showItem(‘add’);
menu.showItem(‘edit’);
menu.showItem(‘delete’);
}
else if(itemId.indexOf(‘H-’) > -1)
{
menu.hideItem(‘add’);
menu.hideItem(‘edit’);
menu.showItem(‘delete’);
}
return true;
})
var custname1=document.getElementById(‘custname’).value;
var time1=document.getElementById(‘time’).value;
var xmlfile1="HTemplate” + custname1 + “" + time1 + “.xml”;
var filename1=“xmlfile/” + xmlfile1;
HTemplatetree.enableDragAndDrop(true);
HTemplatetree.setDragHandler(myDragHandler);
//alert(filename1);
HTemplatetree.loadXML(filename1);
holidaytree=new dhtmlXTreeObject(“treeboxbox_tree2”,“100%”,“100%”,0);
holidaytree.setImagePath(“themes/General/css/imgs/csh_bluefolders/”);
holidaytree.enableDragAndDrop(true);
holidaytree.enableMercyDrag(true);
holidaytree.setDragHandler(myDragHandler);
holidaytree.enableMultiselection(true);
//var custname1=document.getElementById(‘custname’).value;
// var time1=document.getElementById(‘time’).value;
var xmlfile2="Holidays” + custname1 + “_” + time1 + “.xml”;
var filename2=“xmlfile/” + xmlfile2;
// alert(filename2);
holidaytree.loadXML(filename2);
function myDragHandler(idFrom,idTo){
// alert(‘FROM===>’+idFrom);
// alert(‘TO===>’+idTo);
// alert(idFrom.indexOf(‘H-’));
// alert(idTo.indexOf(‘HT-’));
//Checking weather holiday already assigned to template
var subitem=HTemplatetree.getAllSubItems(idTo);
var res=subitem.indexOf(idFrom);
if(res>-1)
{
alert(“Sorry! holiday already exists”);
return false;
}
else if(HTemplatetree.getItemText(idTo)==’’)
{
alert(“Sorry! Try to drop inside Holiday Template”);
return false;
}
if((idFrom.indexOf(‘H-’)==0 && idTo.indexOf(‘HT-’)==0))
{
return true;
}
else
{
alert(“Sorry! You cannot drop here”);
return false;
}
}
The problem isn’t reproduced with the latest tree version.
The answer with the latest library will be sent by email.