PDA

View Full Version : How do you make a grid auto-fit to it's containing panel?



zhegwood
11 Nov 2009, 2:07 PM
I'm rendering a grid panel to an Ext window. I want the grid to fill the window and shrink/expand as necessary if the window is resized while scrolling as necessary inside the grid panel depending on the number of records it's displaying. Basically, height and width are always 100%, but I don't see a config option that will do it.

I looked at the examples and every one of them specifies a height for the grid. Looking at the docs I saw autoHeight, but that will set the height to however many records are being displayed. I've also tried setting the window body to a fit layout to no avail.

basically, it's like this:



var window = new Ext.Window({
//config..
});

var grid = new Ext.grid.GridPanel({
renderTo: window.body,
//config
});

zhegwood
11 Nov 2009, 3:35 PM
Figured it out... Can't use renderTo:

Need to do this:



var window = new Ext.Window({
layout: 'fit'
//config..
});

var grid = new Ext.grid.GridPanel({
//config
});
window.add(grid);
window.doLayout();