View Full Version : Ext.grid.GridPanel.autoExpandColumn dont want to work

23 Feb 2010, 12:39 AM
Hello there :)

I'm trying to set a grid with a column that fit all the empty space.
Using the API Documentation, I've found that the property I'm looking for is autoExpandColumn.

But I tried everything I could to make it work, and nothing came out. I tried this example :
in my code too, but it didn't worked.

The thing is, when I set the autoExpandColumn to a column, this has its size reduced to a tiny size, like 40px and at the right, there is a lot of unused space.

I checked in my css (in case I set something to 40px and that affect the expandable column) but I didn't find anything.

Here is my code :

var gridStore = new Ext.data.ArrayStore ({'fields': [
{'name': 'id'},
{'name': 'name'},
{'name': 'isMod'},
{'name': 'isAdmin'}

var _grid = new Ext.grid.GridPanel ({
'store': gridStore,
'colModel': new Ext.grid.ColumnModel ({
'columns': [
{'id': 'name', 'header': 'Name', 'sortable': true, 'dataIndex': 'name'},
{'header': 'isMod', 'sortable': true, 'dataIndex': 'isMod', 'align': 'center'},
{'header': 'isAdmin', 'sortable': true, 'dataIndex': 'fromDisAdminom', 'align': 'center'}
'autoExpandColumn': 'name',
'stripeRows': true,
renderTo: 'users-displayed-grid'

"users-displayed-grid" is a <div id="users-displayed-grid"></div> that exists in the dom.

Thanks for helping me in this issue :s

(I'm using Ext JS Library 3.1.1)

23 Feb 2010, 5:45 AM
Ok I found where the bug is, and apparently its from extjs core.

In fact, I forgot to mention (I though it wasn't usefull to say it) that my grid is in a tabpanel element. The first displayed tab is not the one that contain the grid. So, to display the grid, the user have to click on a tab.

Has the autoExpandColumn use the total width of the grid to determine the width of the expandable one and regarding to the fact that the grid is not displayed, its width must be the minimum possible, and not the 100% as expected.

I've found it by clicking on one of the headers of the grid. When I click on one of them, the expandable column auto fit the width as expected.

To make it work, I've found two parameter that must be indicated in order to fix this bug, here there are :

'stateId': 'mgrid',
'viewConfig': {
'forceFit': true

I don't know why, but without stateId, the fix don't work ! (regarding to the fact that stateId seems to share absolutely nothing with the problem !!?!).

I don't know if the team is aware of this problem, if it's could be re-created in an other project/script but for me, it works well with these parameters.

(I tested it under firefox 3.5.8 and IE6)

Hope it helps.