re: dhtml tree duplicate children for the same parent

Thank you, logic below worked:

var ids=tree.getAllSubItems(0).split(",")

var check={}

for (var i=0; i<ids.length; i++){

var label=tree.getItemText(ids[i]);

if (!check[label]) check[label]=true;

else tree.deleteItem(ids[i]); //delete duplicate

However, I would like to keep duplicate node highlighted, and return it’s default value ( ex: New Item[1] ). I am trying to use stopEdit(), it doesn’t work:

var hasChildrenCheck = tree.hasChildren(treeitemId);


                var booleanVar = true;

                if(hasChildrenCheck > 0 ){

                var ids = tree.getAllSubItems(treeitemId).split(",");

                var check={};

                for (var i=0; i<ids.length; i++){


                var label=tree.getItemText(ids[i]);

                 if (!check[label]) {




                else {

             //    tree.focusItem(selectedItem);            


            //    tree.deleteItem(ids[i]); //delete duplicate




                } return booleanVar;


Please help,

Thank you

IF you want to prevent duplicates as result of in-tree edit, it can be done as

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;