Uncommited changes synced
[roojs1] / Roo / bootstrap / panel / Grid.js
index b3978f8..2357882 100644 (file)
@@ -5,23 +5,32 @@
  * @constructor
  * Create a new GridPanel.
  * @cfg {Roo.bootstrap.Table} grid The grid for this panel
- * @param {String/Object} config A string to set only the panel's title, or a config object
-
-  new Roo.bootstrap.panel.Grid({
-               grid: .....
-               ....
-  }
-
+ * @cfg {Roo.bootstrap.nav.Simplebar} toolbar the toolbar at the top of the grid.
+ * @param {Object} config A the config object
+  
  */
 
 
 
-Roo.bootstrap.panel.Grid = function(config){
+Roo.bootstrap.panel.Grid = function(config)
+{
     
-  
+      
     this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
-        {tag: "div", cls: "x-layout-grid-wrapper x-layout-inactive-content"}, true);
+        {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
+
+    config.el = this.wrapper;
+    //this.el = this.wrapper;
+    
+      if (config.container) {
+        // ctor'ed from a Border/panel.grid
+        
+        
+        this.wrapper.setStyle("overflow", "hidden");
+        this.wrapper.addClass('roo-grid-container');
 
+    }
+    
     
     if(config.toolbar){
         var tool_el = this.wrapper.createChild();    
@@ -32,20 +41,43 @@ Roo.bootstrap.panel.Grid = function(config){
             delete config.toolbar.items ;
         }
         
-        
+        var nitems = [];
         this.toolbar.render(tool_el);
         for(var i =0;i < ti.length;i++) {
           //  Roo.log(['add child', items[i]]);
             nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
         }
-        ti.items = nitems;
+        this.toolbar.items = nitems;
         
         delete config.toolbar;
     }
-    this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
-    config.el = this.wrapper;
     
     Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
+    config.grid.scrollBody = true;;
+    config.grid.monitorWindowResize = false; // turn off autosizing
+    config.grid.autoHeight = false;
+    config.grid.autoWidth = false;
+    
+    this.grid = new config.grid.xns[config.grid.xtype](config.grid);
+    
+    if (config.background) {
+        // render grid on panel activation (if panel background)
+        this.on('activate', function(gp) {
+            if (!gp.grid.rendered) {
+                gp.grid.render(this.wrapper);
+                gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");   
+            }
+        });
+            
+    } else {
+        this.grid.render(this.wrapper);
+        this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");               
+
+    }
+    //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
+    // ??? needed ??? config.el = this.wrapper;
+    
+    
     
   
     // xtype created footer. - not sure if will work as we normally have to render first..
@@ -59,16 +91,16 @@ Roo.bootstrap.panel.Grid = function(config){
     }
     
     
-    config.grid.monitorWindowResize = false; // turn off autosizing
-    config.grid.autoHeight = false;
-    config.grid.autoWidth = false;
-    this.grid = config.grid;
-    this.grid.getGridEl().replaceClass("x-layout-inactive-content", "x-layout-component-panel");
+    
     
      
 };
 
-Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
+Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content,
+{
+    // private
+    is_resizing : false,
+    
     getId : function(){
         return this.grid.id;
     },
@@ -81,20 +113,43 @@ Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
         return this.grid;    
     },
     
-    setSize : function(width, height){
+    setSize : function(width, height)
+    {
+        if (this.is_resizing) {
+            return;
+        
+        }
+        this.is_resizing = true;
         if(!this.ignoreResize(width, height)){
             var grid = this.grid;
             var size = this.adjustForComponents(width, height);
-            grid.getGridEl().setSize(size.width, size.height);
-            /*
-            var thd = grid.getGridEl().select('thead',true).first();
+            // tfoot is not a footer?
+          
+            
+            var gridel = grid.getGridEl();
+            gridel.setSize(size.width, size.height);
+            
             var tbd = grid.getGridEl().select('tbody', true).first();
-            if (tbd) {
-                tbd.setSize(width, height - thd.getHeight());
+            var thd = grid.getGridEl().select('thead',true).first();
+            var tbf= grid.getGridEl().select('tfoot', true).first();
+
+            if (tbf) {
+                size.height -= tbf.getHeight();
             }
-            */
+            if (thd) {
+                size.height -= thd.getHeight();
+            }
+            
+            tbd.setSize(size.width, size.height );
+            // this is for the account management tab -seems to work there.
+            var thd = grid.getGridEl().select('thead',true).first();
+            //if (tbd) {
+            //    tbd.setSize(size.width, size.height - thd.getHeight());
+            //}
+             
             grid.autoSize();
         }
+        this.is_resizing = false;
     },