This is a migrated thread and some comments may be shown as answers.

Possible to use DropDownAutoWidth to set combo box width?

3 Answers 47 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 1
Veteran
Jay asked on 19 Sep 2013, 08:42 PM
I am specifying DropDownAutoWidth="Enabled" on the RadComboBox and that works just fine; the dropdown list extends to the width of the longest item.

However, when I then select that item, the input area truncates it. Is it possible to get the width of the drop down list and use that to set the width of the combo box itself (prior to the page displaying)? I've tried retrieving the DropDownWidth in the DataBound event, but it appears to be zero. An alternative I've explored is using the method here to determine a width and then set both the DropDownWidth and the combo box's width to that value, but it seems cleaner to get the width the combo box determines itself if that's possible.

3 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 24 Sep 2013, 10:57 AM
Hello Jay,

You could get the DropDownElement width at client-side and set the width to the inputDomElement of the RadComboBox, using jquery and the client-API of the RadComboBox. I have prepared a sample page for you, demonstrating how this could be achieved. Please find it attached.

Regards,
Nencho
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Jay
Top achievements
Rank 1
Veteran
answered on 24 Sep 2013, 04:10 PM
This appears to set the input width after the dropdown closes. While this will prevent the item from being truncated in the display, it does cause the input width to change -- I was hoping I would be able to set the input width to the same width as the dropdown before the dropdown is displayed (or even clicked on, for that matter, ideally prior to the page even displaying).
0
Nencho
Telerik team
answered on 27 Sep 2013, 11:44 AM
Hello Jay,

I am afraid the when the RadComboBox is initialized the dropdown width is not yet calculated, regarding the width of the largest item. Therefore, the suggested approach could not be applied in this scenario. My suggestion is to use the approach in the Code Library, which you had previously referred to.

Regards,
Nencho
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
ComboBox
Asked by
Jay
Top achievements
Rank 1
Veteran
Answers by
Nencho
Telerik team
Jay
Top achievements
Rank 1
Veteran
Share this question
or