Roo.bootstrap.panel.Grid = function(config)
{
this.wrapper = Roo.DomHelper.append(document.body, {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
config.el = this.wrapper;
if (config.container) {
this.wrapper.setStyle("overflow", "hidden");
this.wrapper.addClass('roo-grid-container');
}
if(config.toolbar){
var tool_el = this.wrapper.createChild();
this.toolbar = Roo.factory(config.toolbar);
var ti = [];
if (config.toolbar.items) {
ti = config.toolbar.items ;
delete config.toolbar.items ;
}
var nitems = [];
this.toolbar.render(tool_el);
for(var i =0;i < ti.length;i++) {
nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
}
this.toolbar.items = nitems;
delete config.toolbar;
}
Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
config.grid.scrollBody = true;;
config.grid.monitorWindowResize = false; config.grid.autoHeight = false;
config.grid.autoWidth = false;
this.grid = new config.grid.xns[config.grid.xtype](config.grid);
if (config.background) {
this.on('activate', function(gp) {
if (!gp.grid.rendered) {
gp.grid.render(this.wrapper);
gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
}
});
} else {
this.grid.render(this.wrapper);
this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
}
if (this.footer && !this.footer.el && this.footer.xtype) {
var ctr = this.grid.getView().getFooterPanel(true);
this.footer.dataSource = this.grid.dataSource;
this.footer = Roo.factory(this.footer, Roo);
this.footer.render(ctr);
}
};
Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
getId : function(){
return this.grid.id;
},
getGrid : function(){
return this.grid;
},
setSize : function(width, height){
if(!this.ignoreResize(width, height)){
var grid = this.grid;
var size = this.adjustForComponents(width, height);
var gridel = grid.getGridEl();
gridel.setSize(size.width, size.height);
var tbd = grid.getGridEl().select('tbody', true).first();
var thd = grid.getGridEl().select('thead',true).first();
var tbf= grid.getGridEl().select('tfoot', true).first();
if (tbf) {
size.height -= tbf.getHeight();
}
if (thd) {
size.height -= thd.getHeight();
}
tbd.setSize(size.width, size.height );
var thd = grid.getGridEl().select('thead',true).first();
grid.autoSize();
}
},
beforeSlide : function(){
this.grid.getView().scroller.clip();
},
afterSlide : function(){
this.grid.getView().scroller.unclip();
},
destroy : function(){
this.grid.destroy();
delete this.grid;
Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
}
});