PDA

View Full Version : ComboBox innerList resize



Justin.Parmar
18 Nov 2010, 1:17 AM
Hi,

i want to resize comboBox inner list according to its list component's largest width.
i have done following on comboBox's dataStore's load event, as then only i will have records and can calculate width. but this code also resize the comboBox component. i want only dropdown list to be resized.


onStoreLoad : function(store)
{
var combo = this.container;
var listWidth = 0;
var textMetrics = Ext.util.TextMetrics.createInstance(combo.el);

store.each(function(record) {
var curWidth = textMetrics.getWidth(record.get(combo.displayField));
if (curWidth > listWidth) {
listWidth = curWidth;
}
});

if (listWidth > 0) {
listWidth += this.container.getTriggerWidth(); // to accomodate combo's down arrow.
var cursor = combo.getEl();
combo.updateBox({x:cursor.getX(),y:cursor.getY(),width :listWidth,height:combo.getHeight()});
}
}


any help ?

Justin.Parmar
18 Nov 2010, 2:07 AM
i did it :)
use


combo.listWidth = listWidth;

instead of combo.updateBox()

Though this is not a good way, but there is no any function in combo like setListWidth(),
so have to do it this way.

Anyways, thanks.