title: Kendo tree view adding child nodes dynamically is not working
body: <p>Here, there are two Kendo tree views,First One here (named- #credentialsTreeView") contains nodes with check boxes with parent node, it's  child nodes  and inner children etc,</p>
  
  <p>there is another kendo tree view (named-#CurriculumcustomCredTreeView ),what i want to do is,all the nodes i checked in the first tree view should be added into the second tree view by maintaining the exact parent child relation,for example  if there is a  hierarchy like  <code>parent1==&gt;child1==&gt;child2</code> (which is child of child1),if child2 is checked all it's parent nodes including child2 should be added to second tree view, but here the problem is , 1st:  parent node can be added, as it can be added to the treeview in user i/f and also in datasource,so it is working fine but again on appending it's child node to this added node it is not added with the datasource,so on adding the next child node to it, it is impossible to get the details of the node from datasource to which i need to add the next node,</p>
  
  <p>Kendo version--2013.3.1119.440</p>
  
  <p>please see the code i have used.and please let me know the details as soon as possible.</p>
  
  <pre><code>function onAddToRequirement() 
  
  {
  
  
          var treeViewCraftData = $("#credentialsTreeView").data("kendoTreeView").dataSource.data();//1st tree view which contains initially loaded list of nodes with different levels(with multiple childs and innerchilds with check boxes)
          var treeViewSelectedTextList = [];
          var requirementTreeView = $("#CurriculumcustomCredTreeView").data("kendoTreeView");//2nd tree view to which the selected nodes from 1st tree view to be added dynamically
          $("#credentialsTreeView input[type=checkbox]:checked").closest(".k-item").each(function () {
              treeViewSelectedTextList.push(
                  $(this).closest('.k-item').text()
              );
          });
  
          var treeViewSelectedList = [];
          var currentCraftNode = null;//currently three levels are there as craft==&gt;its levels(can be multiple)==&gt;it's Modules(can be multiple)
          var currentLevelNode = null;
          var currentModuleNode = null;
  
          for (var j = 0; j &lt; treeViewCraftData.length; j++) //treeViewCraftData contains the entire data in the datsource of 1st tree view and looping through it
        {
              if (treeViewCraftData[j].hasChildren)//checking craft  has children
              {
                  var treeViewLevelData = treeViewCraftData[j].children.data();//if so taking all its, levels (craft,s children)
                  currentCraftNode = treeViewCraftData[j];
                  for (var k = 0; k &lt; treeViewLevelData.length; k++) //looping through levels
                {
                      if (treeViewLevelData[k].hasChildren) //checking  levels has children(named modules here)
                    {
                          currentLevelNode = treeViewLevelData[k];
                          var treeViewModuleData = treeViewLevelData[k].children.data(); 
                          for (var l = 0; l &lt; treeViewModuleData.length; l++) //looping through modules(inner children) and checking if it is checked
                             {
                              if (treeViewModuleData[k].checked || $.inArray(treeViewModuleData[k].text, treeViewSelectedTextList) &gt; -1) 
                                 {
                                  currentModuleNode = treeViewModuleData[k];
  
                                  if (requirementTreeView.dataSource._data.length &gt; 0)//added condition to prevent it from adding duplicate nodes to 2nd tree view,in first case directly it goes to else part
                                   {
                                      var dataItemcraft1 = null;
                                      var dataItemlevel1 = null;
                                      $(requirementTreeView.dataSource.data()).each(function() 
                                        {
                                          if (this.id !== currentCraftNode.id) 
                                          {     
                                              requirementTreeView.append({//appending 1st node
                                                  Name: currentCraftNode.Name,
                                                  id: currentCraftNode.id,
                                                  hasChildren:currentCraftNode.hasChildren,
                                                  //items: treeViewSelectedList.length != 0 ? treeViewSelectedList : null
                                              }, null); 
                                          }
                                      });
  
                                      dataItemcraft1 = requirementTreeView.dataSource.get(currentCraftNode.id);
  
                                      $(requirementTreeView.dataSource.data()).each(function() {
  
                                          if (this.id !== currentLevelNode.id) {//appending 2nd node to first node
                                              requirementTreeView.append({
                                                  Name: currentLevelNode.Name,
                                                  id: currentLevelNode.id,
                                                  hasChildren: currentLevelNode.hasChildren,
                                                  }, requirementTreeView.dataSource.get(dataItemcraft1.uid));
                                          }
                                      });
  
                                      dataItemlevel1 = requirementTreeView.dataSource.get(currentCraftNode.id);//here it throws exception  as above node is not added to the datsource
  
                                      $(requirementTreeView.dataSource.data()).each(function() {//code to append 3rd node to above added node
                                          //ebugger;
                                          if (this.id !== currentModuleNode.id) {
  
                                              requirementTreeView.append({
                                                  Name: currentModuleNode.Name,
                                                  id: currentModuleNode.id,
                                                  hasChildren: currentModuleNode.hasChildren,
                                                  //items: treeViewSelectedList.length != 0 ? treeViewSelectedList : null
                                              }, requirementTreeView.dataSource.get(dataItemlevel1.uid));
                                          }
                                      });
  
                                      dataItemcraft1 = null;
                                      dataItemlevel1 = null;
  
                                  } else
                                  {
                                      requirementTreeView.append//appending 1st node
                                       ({
                                          Name: currentCraftNode.Name,
                                          id: currentCraftNode.id,
                                          hasChildren: currentCraftNode.hasChildren,
                                          Value: currentCraftNode.id
                                      });
  
  
                                      var dataItemcraft = requirementTreeView.dataSource.get(currentCraftNode.id);//working fine
  
                                      requirementTreeView.append//appending 2nd node to first node
                                          ({
                                          Name: currentLevelNode.Name,
                                          id: currentLevelNode.id,
                                          hasChildren: currentLevelNode.hasChildren,
                                          }, requirementTreeView.findByUid(dataItemcraft.uid));
  
                                      requirementTreeView.expand(requirementTreeView.findByUid(dataItemcraft.uid));
  
                                      var dataItemlevel = requirementTreeView.dataSource.get(currentLevelNode.id);//here it throws exception  as above node is not added to the datsource
  
                                      requirementTreeView.append({
                                          Name: currentModuleNode.Name,
                                          id: currentModuleNode.id,
                                          hasChildren: currentModuleNode.hasChildren,
                                          //items: treeViewSelectedList.length != 0 ? treeViewSelectedList : null
                                      }, requirementTreeView.findByUid(dataItemlevel.uid));
  
                                      requirementTreeView.expand(requirementTreeView.findByUid(dataItemlevel.uid));
  
                                      dataItemcraft = null;
                                      dataItemlevel = null;
                                  }
  
                              }
                          }
                      } else {
  
                  }
  
  
  
              }
          }
  
  
      }
  </code></pre>