View Full Version : Adjusting column width

10 May 2012, 7:07 PM
Hi All,

I am using ExtJs 4.1 framework. I have a grid in which all the columns are dynamically added. I want to adjust the width of the columns based on the content of first row. So If the content is number, I want to set the width of column to100px, if the content is string then the column width should be 200px if the content of the column is date then I want to change the width to 50 px. How can I do this?

Please provide your suggestions.

Thanks in advance.

10 May 2012, 11:21 PM
Ext.grid.column.Column has a setWidth() function. You could listen to the 'afterrender' event, and then iterate through the columns, calling setWidth() with the value you want to set. Make sure your grid doesnt have 'forceFit' set to true though, otherwise this probably wont work.