Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Victor on Dec 19, 2008 08:45
open dhtmlx forum
dhtmlxTree; dhtmlxDataProcessor - cannot cancek node insertion

Hi,

I use drag'n'drop on a tree to copy a node from one folder to another (mercy drag).
On the server side I detect that the operation violates some business rules and cannot be completed.
I return an error XML, like this:
<data>
    <action sid="p.NL_P_030.o.2_1229703958197" type="error">Cannot copy node</action>
</data>
On the client side I want to show the message and get rid of the node in the target folder:
dp.defineAction("error", myErrorHandler);
function myErrorHandler(tag) {
    alert(tag.firstChild.data);
    var sid = tag.getAttribute("sid");//sid - temp id assigned by dhmlx
    dp.stopOnError = true;
    myTree.deleteItem(sid, false);
    return false;
}

The problem is that though the node (which failed to get inserted on the server side) gets stroked out it still remains in the target folder.
How can I get rid of the node (effectively cancel insertion on the client because it failed on the server)?

Thanks a lot,
Victor
Answer posted by Support on Dec 20, 2008 03:09
Update your code as

function myErrorHandler(tag) { 
  var sid = tag.getAttribute("sid");//sid - temp id assigned by dhmlx 
//  dp.stopOnError = true; 
  myTree.deleteItem(sid, false); 
  myTree.deleteItem(sid, false); //dupplicate call to fully remove row
  dp.setUpdated(sid,false); //remove updated flag from the item
  return false; 
}

Answer posted by Victor on Dec 22, 2008 09:21
Thanks a lot, it works fine now