PDA

View Full Version : Toggling forceFit on a grid



hobophobik
25 Nov 2010, 5:56 AM
Hi,

I'm having a little trouble with a small plugin I'm writing. The plugin should add a button to a grids tbar and allow the user to toggle forcefit on and off.

I'm finding that toggling almost works, but in an odd fashion: I can only toggle the button on and off once before it begins to do nothing. When switching forceFit off, the refresh() renders some of the columns slightly wider than their original width. I've trawled through some of the GridView code, but haven't been able to figure it out.

I'd be grateful for a little help. Thanks.

Example (http://test.hughgallagher.co.uk/static/useradmin.htm)



Ext.namespace('LBA.plugins');

LBA.plugins.GridAutoFit = function(config) {
Ext.apply(this, config);
};

Ext.extend(LBA.plugins.GridAutoFit, Ext.util.Observable, {
init: function(grid) {
grid.getTopToolbar().add({
text:'Fit To Screen',
listeners:{
click:function(button){
var view = grid.getView();
view.forceFit = (view.forceFit === true) ? false : true;
view.refresh();
button.toggle(view.forceFit);
}
}
});
},
})