PDA

View Full Version : Setting BoundList minWidth to the width of a parent ComboBox without matchFieldWidth



Lucy.
9 Oct 2014, 7:56 AM
Hi all,

I'm using listConfig on a ComboBox to auto-resize to the widest option in the drop-down. This is great when the list items are wider than the ComboBox, but not what I want when the list items are thinner. I would like to set minWidth on the BoundList to be the current width of the ComboBox and I can't figure it out. Here's a snippet of what I have so far..


Ext.define('MyComboBox', {
extend: 'Ext.form.field.ComboBox',

emptyText: '------',
queryMode: 'local',
displayField: 'foo',
valueField: 'bar',
autoSelect: true,
typeAhead: true,
matchFieldWidth: false,
listConfig: {
width: 'auto'
},
...

Any help appreciated!

watertrac_dev
9 Oct 2014, 10:42 AM
How about this?

bim

Lucy.
9 Oct 2014, 11:02 AM
Thanks very much, worked like a charm.

Lucy.
9 Oct 2014, 11:04 AM
How about this?


I somehow managed to mark my reply as the best answer -- apologies for that and thanks again for the help.

watertrac_dev
9 Oct 2014, 11:21 AM
No worries. Perhaps a forum moderator can correct the selection of the best answer.

Lucy.
10 Oct 2014, 2:55 AM
Just to add, I switched the function to the beforeshow listener to accommodate changes in the parent's size due to window resizes, etc.

bk0

SebTardif
20 Sep 2016, 5:45 AM
Somehow that didn't work always, I ended up to use:


listeners: {
beforeshow: function(picker) {
picker.minWidth = Math.max([picker.up('combobox').inputEl.getSize().width],picker.minWidth);
}
}