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     this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
26     config.el = this.wrapper;
27     
28     Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
29     
30     if(this.toolbar){
31         
32         
33         this.toolbar.el.insertBefore(this.wrapper.dom.firstChild);
34     }
35     // xtype created footer. - not sure if will work as we normally have to render first..
36     if (this.footer && !this.footer.el && this.footer.xtype) {
37         
38         var ctr = this.grid.getView().getFooterPanel(true);
39         this.footer.dataSource = this.grid.dataSource;
40         this.footer = Roo.factory(this.footer, Roo);
41         this.footer.render(ctr);
42         
43     }
44     
45     
46     config.grid.monitorWindowResize = false; // turn off autosizing
47     config.grid.autoHeight = false;
48     config.grid.autoWidth = false;
49     this.grid = config.grid;
50     this.grid.getGridEl().replaceClass("x-layout-inactive-content", "x-layout-component-panel");
51     
52      
53 };
54
55 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
56     getId : function(){
57         return this.grid.id;
58     },
59     
60     /**
61      * Returns the grid for this panel
62      * @return {Roo.bootstrap.Table} 
63      */
64     getGrid : function(){
65         return this.grid;    
66     },
67     
68     setSize : function(width, height){
69         if(!this.ignoreResize(width, height)){
70             var grid = this.grid;
71             var size = this.adjustForComponents(width, height);
72             grid.getGridEl().setSize(size.width, size.height);
73             /*
74             var thd = grid.getGridEl().select('thead',true).first();
75             var tbd = grid.getGridEl().select('tbody', true).first();
76             if (tbd) {
77                 tbd.setSize(width, height - thd.getHeight());
78             }
79             */
80             grid.autoSize();
81         }
82     },
83      
84     
85     
86     beforeSlide : function(){
87         this.grid.getView().scroller.clip();
88     },
89     
90     afterSlide : function(){
91         this.grid.getView().scroller.unclip();
92     },
93     
94     destroy : function(){
95         this.grid.destroy();
96         delete this.grid;
97         Roo.bootstrap.panel.Grid.superclass.destroy.call(this); 
98     }
99 });