I am currently trying to find a way to automatically set the width of dropdownlist depending on drop down items
Thanks
Jing
3 Answers, 1 is accepted
0
Dimo
Telerik team
answered on 18 Dec 2012, 03:35 PM
Hi Jing,
By design, the DropDownList dropdown width depends on the DropDownList width, not vice-versa.
What you can do is check the length of the longest DropDownList item server-side (from the widget's datasource) and set some approximate width to the widget, based on the used font size.
All the best,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Thanks Dimo. Could you provide me some sample code to your solution? I am a bit new to Kendu now.
Best Regards
Jing
0
Dimo
Telerik team
answered on 19 Dec 2012, 09:26 AM
Hi Jing,
What I suggested is not related to Kendo UI, so you should be able to do it based on your current knowledge.
1. You need to retrieve the DataSource you are using and iterate through the items.
2. Find the item with longest text and count the characters.
3. Set width to the DropDownList by using
where "25" is the space required by side paddings and the open button. You can use a larger number to increase the space between the item text and the open button.
Regards,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!