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