Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Inna on Dec 01, 2008 12:17
open dhtmlx forum
dhtml tree duplicate children for the same parent

Hello,

I need to eliminate duplicate names for children having same parent in dhtml tree. For example:

PARENT
CHILD 1
CHILD 1 // should not be allowed.

Can you please give an example of how this can be accomplished on client side, prior to serialization and submitting XML to be processed on a server.

Thank you.
Answer posted by Support on Dec 02, 2008 01:57
can be done as

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
}