Fix #5665 - pre-commit hooks for roojs
[roojs1] / Roo / tree / TreeNode.js
index 6c35a55..e393fa0 100644 (file)
@@ -18,7 +18,7 @@
  * @cfg {Boolean} allowDrop false if this node cannot be drop on
  * @cfg {Boolean} disabled true to start the node disabled
  * @cfg {String} icon The path to an icon for the node. The preferred way to do this
- * is to use the cls or iconCls attributes and add the icon via a CSS background image.
+ *    is to use the cls or iconCls attributes and add the icon via a CSS background image.
  * @cfg {String} cls A css class to be added to the node
  * @cfg {String} iconCls A css class to be added to the nodes icon element for applying css background images
  * @cfg {String} href URL of the link used for the node (defaults to #)
  * @cfg {Boolean} singleClickExpand True for single click expand on this node
  * @cfg {Function} uiProvider A UI <b>class</b> to use for this node (defaults to Roo.tree.TreeNodeUI)
  * @cfg {Boolean} checked True to render a checked checkbox for this node, false to render an unchecked checkbox
- * @cfg {Array} children Array of Children to be added when created..
-  
  * (defaults to undefined with no checkbox rendered)
  * @constructor
  * @param {Object/String} attributes The attributes/config for the node or just a string with the text for the node
  */
-Roo.tree.TreeNode = function(attributes)
-{
+Roo.tree.TreeNode = function(attributes){
     attributes = attributes || {};
     if(typeof attributes == "string"){
         attributes = {text: attributes};
@@ -153,18 +150,22 @@ Roo.tree.TreeNode = function(attributes)
      * @type TreeNodeUI
      */
     this.ui = new uiClass(this);
-     
-    if (attributes.children) {
-        Roo.each(attributes.children, function(c) {
-            this.appendChild(new Roo.tree.TreeNode(c));
-        }, this);
-        
+    
+    // finally support items[]
+    if (typeof(this.attributes.items) == 'undefined' || !this.attributes.items) {
+        return;
     }
     
-};
-Roo.extend(Roo.tree.TreeNode, Roo.data.Node, {
+    
+    Roo.each(this.attributes.items, function(c) {
+        this.appendChild(Roo.factory(c,Roo.Tree));
+    }, this);
+    delete this.attributes.items;
     
     
+    
+};
+Roo.extend(Roo.tree.TreeNode, Roo.data.Node, {
     preventHScroll: true,
     /**
      * Returns true if this node is expanded
@@ -208,7 +209,8 @@ Roo.extend(Roo.tree.TreeNode, Roo.data.Node, {
 
     // these methods are overridden to provide lazy rendering support
     // private override
-    appendChild : function(){
+    appendChild : function()
+    {
         var node = Roo.tree.TreeNode.superclass.appendChild.apply(this, arguments);
         if(node && this.childrenRendered){
             node.render();