PDA

View Full Version : Resize combobox to fit its content



itrushn
26 Apr 2010, 2:22 PM
There are many thread to solve this issue, but I wasnít able to get any of them work. It seems I am missing something minor.
I need to resize combobox to fit its content when itís first created. I do not need to worry about resizing it when content is changing.
Is there any working examples using Extjs 3.2?

My Code:


var store = new Ext.data.ArrayStore({
fields: ['view', 'value', 'defaultselect'],
data: Ext.configdata.dataCP
});

comboCPU = new Ext.form.ComboBox({
tpl: '<tpl for="."><div class="x-combo-list-item"><b>{view}</b><br /></div></tpl>',
store: store,
displayField: 'view',
width: 600,
typeAhead: true,
forceSelection: true,
mode: 'local',
triggerAction: 'all',
editable: false,
emptyText: 'empty text',
selectOnFocus: true,
listeners: { select: AdjustPrice, change: AdjustPrice, beforeselect: function (combo, record, index) { return ('false' == record.data.disabled); } },
applyTo: 'confelement'
});

Keylan
26 Apr 2010, 2:25 PM
I believe the only thing restricting your ComboBox from automatically sizing to it's contents is where you set width: 600. I believe this will force the ComboBox to a static width of 600 pixels. If you would like to have it automatically size, but give it a minimum width - try getting rid of the width: 600 line, and using minListWidth:

itrushn
27 Apr 2010, 9:56 AM
Keylan
Thanks for your response, however it didnít help. Now combobox became even shorter, and list is still doesnít display full values.

http://img28.imageshack.us/img28/7665/4272010105134am.png

itrushn
27 Apr 2010, 9:57 AM
Does anyone else know how I can make sure that combobox and list are able to fully display option?