Is there a way to autosize the width of the combo input?

Hi My old friends,

As we know there’s a method setSize() to set the width of the combo input . and the method enableOptionAutoWidth(1) to make sure set automatic width for list of combo options to let’s see the complete option .
My question is :
How can autoresize the width of the combo input? So i we can make the combo input as long as the longest option ? If not , the option list will be longer than the input , i think that’s not friendly to us .

I have thought a way : first get the width of the longest option and then use the method setSize using the width to make sure the input as long as the options . But i don’t know how to access all the options elements and get the width of them ? If you can provide the detail code or some demo , it’s will very helpful for me .

Many thanks .

Any update ? I really need to find the way to implement that .

Hi,

it is possible to get the option width only after the list is visible (it is possible to resize the combo after the list opens for the first time.). We can provide you this solution if you want.

You may try to implement own solution. Here some hints:

to iterate through all options:
for ( var i=0; i<combo.optionsArr.length; i++){
/your code here/
}

option text:
combo.optionsArr[i].text

html object of the option:
combo.optionsArr[i].content