View Full Version : Force column widths to redraw?

18 Apr 2012, 8:49 AM

This might sound like a simple request, but I've been pulling my hair out over it :D

I have a stateful grid on which I'm using the columnModel's setColumnWidth method. Once this new width has been applied I'm simply calling a refresh() on the grid's view. This half works, as it then correctly lines the columns up with the headers - however, it does not redraw the columns and follow the forceFit: true config which is applied to the grid (it doesn't auto fill 100% of the container - it simply seems to retain all the existing widths as stored in the previous state with one new width attribute).

I can already force the grid to redraw correctly by calling some very "hacky" methods, such as hiding and then showing a column (using setHidden), but this isn't exactly ideal. Isn't there some correct method/event I can fire for this to do the same action?

18 Apr 2012, 9:02 AM
Here's an example image to help illustrate the issue.

1) Grid loads naturally

2) setColumnWidth has been applied to the first column, and refresh called on the grid view. As you can see the columns have all been pushed off to the right.

3) My hack attempt at fixing this. I simply hide and then show one of the columns, which fires an event to redraw the column widths correctly. Can I not fire this event manually without jumping through hoops?


9 May 2012, 6:39 AM
Hi Billigogs,

You must use "forceFit : true " config under the viewConfig : { forceFit: true }

I hope this will work fine .

9 May 2012, 7:02 AM
Hi sword-it,

Thanks for the answer, but the grid already has this applied. I guess I would need to provide a code example for this to make sense :)