Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Inna on Dec 03, 2008 08:16
open dhtmlx forum
re: dhtml tree duplicate children for the same parent

Hello,

Functionality below worked, thank you.

tree.attachEvent("onEdit",function(stage,id,tree,value){
     if (stage==2){ //before editor closed
          var ids=tree.getAllSubItems(0).split(",");
          for (var i=0; i<ids.length; i++)
               if (tree.getItemText(ids[i])==value) return false; //revert to old value if there is a duplicate
    } 
    return true;
})

 

Can we keep focus on the node that was a duplicate and was reverted to old value? So it will be still editable.

Answer posted by Support on Dec 04, 2008 01:58
There is no way to keep focus, but it possible to refocus on the same action by using 

  var ids=tree.getAllSubItems(0).split(",");
  for (var i=0; i<ids.length; i++)
  if (tree.getItemText(ids[i])==value) {
             var sid=ids[i];
             window.setTimeout(function(){
                    tree.selecteItem(sid);
                    tree.editItem(sid);
             },1);
             return false;
  }

Answer posted by Inna on Dec 04, 2008 08:13

 it worked.

Thank you very much for your help