Roo/bootstrap/layout/Border.js
[roojs1] / Roo / bootstrap / layout / Border.js
index 54ccc0e..d92fdf6 100644 (file)
@@ -28,6 +28,7 @@ Roo.bootstrap.layout.Border = function(config){
     Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
     
     
+    
     Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
         if(config[region]){
             config[region].region = region;
@@ -52,12 +53,12 @@ Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
             var r = this.factory(config);
            this.bindRegion(r);
         }
-        return this.regions[config.target];
+        return this.regions[config.region];
     },
 
     // private (kinda)
     bindRegion : function(r){
-        this.regions[r.target] = r;
+        this.regions[r.config.region] = r;
         
         r.on("visibilitychange",    this.layout, this);
         r.on("paneladded",          this.layout, this);
@@ -76,6 +77,14 @@ Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
         if(this.updating) {
             return;
         }
+        
+        // render all the rebions if they have not been done alreayd?
+        Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
+            if(this.regions[region] && !this.regions[region].bodyEl){
+                this.regions[region].onRender(this.el)
+            }
+        },this);
+        
         var size = this.getViewSize();
         var w = size.width;
         var h = size.height;
@@ -286,14 +295,19 @@ layout.addxtype({
             delete cfg.items;
         }
         var nb = false;
+       
+       if (cfg.region == 'center') {
+           Roo.log("Center" + cfg.title);
+       }
+       
         
         switch(cfg.xtype) 
         {
             case 'Content':  // ContentPanel (el, cfg)
             case 'Scroll':  // ContentPanel (el, cfg)
             case 'View': 
-                cfg.autoCreate = true;
-                ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
+                cfg.autoCreate = cfg.autoCreate || true;
+                ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
                 //} else {
                 //    var el = this.el.createChild();
                 //    ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
@@ -334,36 +348,44 @@ layout.addxtype({
                 this.add(region, ret);
                 nb = {}; /// find first...
                 break;
-                /*
-            case 'GridPanel': 
             
+            case 'Grid':
+                
                 // needs grid and region
                 
                 //var el = this.getRegion(region).el.createChild();
-                var el = this.el.createChild();
+                /*
+                 *var el = this.el.createChild();
                 // create the grid first...
+                cfg.grid.container = el;
+                cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
+                */
                 
-                var grid = new Roo.grid[cfg.grid.xtype](el, cfg.grid);
-                delete cfg.grid;
                 if (region == 'center' && this.active ) {
                     cfg.background = false;
                 }
-                ret = new Roo[cfg.xtype](grid, cfg); // new panel!!!!!
+                
+                ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
                 
                 this.add(region, ret);
+                /*
                 if (cfg.background) {
+                    // render grid on panel activation (if panel background)
                     ret.on('activate', function(gp) {
                         if (!gp.grid.rendered) {
-                            gp.grid.render();
+                    //        gp.grid.render(el);
                         }
                     });
                 } else {
-                    grid.render();
+                  //  cfg.grid.render(el);
                 }
+                */
                 break;
            
-           */
-            case 'Border': // it can get called on it'self...
+           
+            case 'Border': // it can get called on it'self... - might need to check if this is fixed?
+                // it was the old xcomponent building that caused this before.
+                // espeically if border is the top element in the tree.
                 ret = this;
                 break; 
                 
@@ -384,8 +406,7 @@ layout.addxtype({
                     return null;
              
                                 
-             // GridPanel (grid, cfg)
-            
+             
         }
         this.beginUpdate();
         // add children..
@@ -435,7 +456,7 @@ layout.addxtype({
         cfg.mgr = this;
         
         var r = Roo.bootstrap.layout;
-        
+        Roo.log(target);
         switch(target){
             case "north":
                 return new r.North(cfg);