Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gridpanel auto resize on window resize

Tags:

extjs

I'm using the array-grid extjs example to try and fit a gridpanel into a container window. The problem is on resizing the container window, the gridpanel doesn't automatically fit the new size. As I understand it that's how it's supposed to work.

Here's the link to the example: http://www.extjs.com/deploy/dev/examples/grid/array-grid.html

What I've done is changed the following..

// Added to gridpanel config
layout: 'fit',
viewConfig: {
    forceFit: true
}

// Window container
var gridWindow = new Ext.Window({
    items: [
        grid
    ]
});

// Instead of grid.render, use gridWindow.show();
gridWindow.show();

result

like image 933
imnotneo Avatar asked Mar 25 '10 07:03

imnotneo


3 Answers

layout: 'fit',

should go into the gridWindow configuration! The layout manager arranges the children of a panel, but the grid is the child.

like image 79
Erich Kitzmueller Avatar answered Oct 03 '22 07:10

Erich Kitzmueller


I'm using the following workaround:

Ext.onReady(function () {
    var grid = ... //define your grid here

    Ext.EventManager.onWindowResize(function () {
        grid.setSize(undefined, undefined);
    });
});

Extjs v4.0.7

like image 24
Tiago Avatar answered Oct 03 '22 08:10

Tiago


I solved this by wrapping my gridpanel into an Ext.Panel, with a layout property set to 'fit'. The grid panel (with a viewConfig also containing forceFit: 'true' now is resized automatically when the window is resized

like image 44
dark.gixxer Avatar answered Oct 03 '22 08:10

dark.gixxer