/**
 * Blind that contains an Ext.grid.GridPanel.
 */
Ext.ux.GridBlind = function(el, win, config) {
    Ext.ux.GridBlind.superclass.constructor.call(this, el, win, config);
    Ext.apply(this.gridConfig, config || {}, {
        autoHeight: false,
        viewConfig: {
            forceFit: false
         }
    });
  
    this.grid = new Ext.grid.GridPanel(this.gridConfig);
};

Ext.extend(Ext.ux.GridBlind, Ext.ux.WindowBlind, { 
    /**
     * Override
     * Render the grid to the body prior to the first show.
     */
    onBeforeShow: function() {
        if (!this.grid.rendered) {
            this.grid.render(this.body);                
        }
    
        Ext.ux.GridBlind.superclass.onBeforeShow.call(this);
    },  
    
    /**
     * The grid's width should equal the body's width.
     */
    syncWidth: function() {
        Ext.ux.GridBlind.superclass.syncWidth.call(this);
        this.grid.setWidth(this.body.getWidth());   
    },
    
    /**
     * 
     */
    syncHeight: function() {
        var h = this.winBodyEl.getComputedHeight();
        if (this.el.getComputedHeight() > h) {
            var gh = h - this.bwrap.getPadding('tb') - this.footer.getComputedHeight();
            this.grid.setHeight(gh);
            this.grid.autoHeight = false;
            this.grid.getView().refresh(true);  // private access
        }
    },

    /**
     *
     */
    onBeforeHide: function() {
        this.grid.autoHeight = true;
        Ext.ux.GridBlind.superclass.onBeforeHide.call(this);
    },

    /**
     * Override to destory the grid.
     */
    destroy: function() {
        this.grid.destroy();
        Ext.ux.GridBlind.superclass.destroy.call(this);
    }   
});