PDA

View Full Version : Combo Autowidth



aleczapka
24 Sep 2009, 2:20 AM
hi all,

Not sure if this is the right forum for that but, I've seen many implementation on how to automatically adjust combo width, including using ext.overwrite, overloading onInit etc...

Here is the simple fix for that:

Call it from withing the onExpand event (or onLoad or onTriggerClick) but onExpand should work.
Replace isNullOrUndefined() with typeof 'undefined'


,fixListWidth: function() {
if (!isNullOrUndefined(this.list) && !isNullOrUndefined(this.innerList)) {
this.list.setWidth('auto');
this.innerList.setWidth('auto');

var lw = this.list.getSize().width;
this.list.setWidth(this.getSize().width);
this.innerList.setWidth(this.getSize().width - this.list.getFrameWidth('lr'));

if (lw > this.getSize().width) {
this.list.setWidth('auto');
this.innerList.setWidth('auto');
}
}
}


Here is the combo definition


,listWidth: 'auto'
,minListWidth: 'auto'


Works in Firefox and Chrome (not sure about IE, but I don't care for IE)