Roo/bootstrap/panel/Grid.js
[roojs1] / Roo / bootstrap / panel / Grid.js
1
2 /**
3  * @class Roo.bootstrap.panel.Grid
4  * @extends Roo.bootstrap.panel.Content
5  * @constructor
6  * Create a new GridPanel.
7  * @cfg {Roo.bootstrap.Table} grid The grid for this panel
8  * @param {String/Object} config A string to set only the panel's title, or a config object
9
10   new Roo.bootstrap.panel.Grid({
11                 grid: .....
12                 ....
13   }
14
15  */
16
17
18
19 Roo.bootstrap.panel.Grid = function(config){
20     
21   
22     this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
23         {tag: "div", cls: "x-layout-grid-wrapper x-layout-inactive-content"}, true);
24
25     
26     if(this.toolbar){
27         var tool_el = this.el.createChild();    
28         this.toolbar = Roo.factory(this.toolbar);
29         this.toolbar.render(tool_el);
30         
31     }
32     this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
33     config.el = this.wrapper;
34     
35     Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
36     
37     if(this.toolbar){
38         
39     }
40     // xtype created footer. - not sure if will work as we normally have to render first..
41     if (this.footer && !this.footer.el && this.footer.xtype) {
42         
43         var ctr = this.grid.getView().getFooterPanel(true);
44         this.footer.dataSource = this.grid.dataSource;
45         this.footer = Roo.factory(this.footer, Roo);
46         this.footer.render(ctr);
47         
48     }
49     
50     
51     config.grid.monitorWindowResize = false; // turn off autosizing
52     config.grid.autoHeight = false;
53     config.grid.autoWidth = false;
54     this.grid = config.grid;
55     this.grid.getGridEl().replaceClass("x-layout-inactive-content", "x-layout-component-panel");
56     
57      
58 };
59
60 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
61     getId : function(){
62         return this.grid.id;
63     },
64     
65     /**
66      * Returns the grid for this panel
67      * @return {Roo.bootstrap.Table} 
68      */
69     getGrid : function(){
70         return this.grid;    
71     },
72     
73     setSize : function(width, height){
74         if(!this.ignoreResize(width, height)){
75             var grid = this.grid;
76             var size = this.adjustForComponents(width, height);
77             grid.getGridEl().setSize(size.width, size.height);
78             /*
79             var thd = grid.getGridEl().select('thead',true).first();
80             var tbd = grid.getGridEl().select('tbody', true).first();
81             if (tbd) {
82                 tbd.setSize(width, height - thd.getHeight());
83             }
84             */
85             grid.autoSize();
86         }
87     },
88      
89     
90     
91     beforeSlide : function(){
92         this.grid.getView().scroller.clip();
93     },
94     
95     afterSlide : function(){
96         this.grid.getView().scroller.unclip();
97     },
98     
99     destroy : function(){
100         this.grid.destroy();
101         delete this.grid;
102         Roo.bootstrap.panel.Grid.superclass.destroy.call(this); 
103     }
104 });