Roo/ViewPanel.js
[roojs1] / Roo / ViewPanel.js
1 /*
2  * Based on:
3  * Ext JS Library 1.1.1
4  * Copyright(c) 2006-2007, Ext JS, LLC.
5  *
6  * Originally Released Under LGPL - original licence link has changed is not relivant.
7  *
8  * Fork - LGPL
9  * <script type="text/javascript">
10  */
11
12 /**
13  * @class Roo.GridPanel
14  * @extends Roo.ContentPanel
15  * @constructor
16  * Create a new GridPanel.
17  * @param {Roo.grid.Grid} grid The grid for this panel
18  * @param {String/Object} config A string to set only the panel's title, or a config object
19  */
20 Roo.ViewPanel = function(el, config){
21     
22   
23     this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
24         {tag: "div", cls: "x-layout-grid-wrapper x-layout-inactive-content"}, true);
25         
26     this.wrapper.dom.appendChild(el.dom);
27     
28     Roo.ViewPanel.superclass.constructor.call(this, this.wrapper, 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.wrapper.el; // this.getView().getFooterPanel(true);
37         this.footer.dataSource = this.view.store;
38         this.footer = Roo.factory(this.footer, Roo);
39         
40     }
41     //??? create teh view???
42     
43     //grid.monitorWindowResize = false; // turn off autosizing
44     //grid.autoHeight = false;
45     //grid.autoWidth = false;
46     //this.grid = grid;
47     //this.grid.getGridEl().replaceClass("x-layout-inactive-content", "x-layout-component-panel");
48 };
49
50 Roo.extend(Roo.ViewPanel, Roo.ContentPanel, {
51     getId : function(){
52         return this.view.id;
53     },
54     
55     /**
56      * Returns the grid for this panel
57      * @return {Roo.grid.Grid} 
58      */
59     getGrid : function(){
60         return this.view;    
61     },
62     
63     setSize : function(width, height){
64         if(!this.ignoreResize(width, height)){
65             var grid = this.grid;
66             var size = this.adjustForComponents(width, height);
67             grid.getGridEl().setSize(size.width, size.height);
68             grid.autoSize();
69         }
70     },
71     
72     beforeSlide : function(){
73         this.grid.getView().scroller.clip();
74     },
75     
76     afterSlide : function(){
77         this.grid.getView().scroller.unclip();
78     },
79     
80     destroy : function(){
81         this.grid.destroy();
82         delete this.grid;
83         Roo.GridPanel.superclass.destroy.call(this); 
84     }
85 });