Roo/bootstrap/panel/Grid.js
[roojs1] / Roo / bootstrap / panel / Grid.js
1
2 /**
3  * @class Roo.GridPanel
4  * @extends Roo.ContentPanel
5  * @constructor
6  * Create a new GridPanel.
7  * @param {Roo.grid.Grid} 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(grid, 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(grid.getGridEl().dom);
26     
27     Roo.bootstrap.panel.Grid.superclass.constructor.call(this, this.wrapper, config);
28     
29     if(this.toolbar){
30         this.toolbar.el.insertBefore(this.wrapper.dom.firstChild);
31     }
32     // xtype created footer. - not sure if will work as we normally have to render first..
33     if (this.footer && !this.footer.el && this.footer.xtype) {
34         
35         this.footer.container = this.grid.getView().getFooterPanel(true);
36         this.footer.dataSource = this.grid.dataSource;
37         this.footer = Roo.factory(this.footer, Roo);
38         
39     }
40     
41     config.grid.monitorWindowResize = false; // turn off autosizing
42     config.grid.autoHeight = false;
43     config.grid.autoWidth = false;
44     this.grid = config.grid;
45     this.grid.getGridEl().replaceClass("x-layout-inactive-content", "x-layout-component-panel");
46 };
47
48 Roo.extend(Roo.bootstrap.panel.Grid, Roo.ContentPanel, {
49     getId : function(){
50         return this.grid.id;
51     },
52     
53     /**
54      * Returns the grid for this panel
55      * @return {Roo.grid.Grid} 
56      */
57     getGrid : function(){
58         return this.grid;    
59     },
60     
61     setSize : function(width, height){
62         if(!this.ignoreResize(width, height)){
63             var grid = this.grid;
64             var size = this.adjustForComponents(width, height);
65             grid.getGridEl().setSize(size.width, size.height);
66             grid.autoSize();
67         }
68     },
69     
70     beforeSlide : function(){
71         this.grid.getView().scroller.clip();
72     },
73     
74     afterSlide : function(){
75         this.grid.getView().scroller.unclip();
76     },
77     
78     destroy : function(){
79         this.grid.destroy();
80         delete this.grid;
81         Roo.bootstrap.panel.Grid.superclass.destroy.call(this); 
82     }
83 });