sync
[roojs1] / Roo / bootstrap / panel / Grid.js
index ab1b388..be5c735 100644 (file)
@@ -5,18 +5,32 @@
  * @constructor
  * Create a new GridPanel.
  * @cfg {Roo.bootstrap.Table} grid The grid for this panel
+ * @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();    
@@ -38,10 +52,32 @@ Roo.bootstrap.panel.Grid = function(config){
         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..
@@ -55,11 +91,7 @@ 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");
+    
     
      
 };
@@ -81,15 +113,30 @@ Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
         if(!this.ignoreResize(width, height)){
             var grid = this.grid;
             var size = this.adjustForComponents(width, height);
-            var gridel = grid.getGridEl()
+            // tfoot is not a footer?
+          
+            
+            var gridel = grid.getGridEl();
             gridel.setSize(size.width, size.height);
-            /*
-            var thd = grid.getGridEl().select('thead',true).first();
+            
             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();
         }
     },