Possible to use DropDownAutoWidth to set combo box width?

4 posts, 0 answers
  1. Jay
    Jay avatar
    59 posts
    Member since:
    Dec 2011

    Posted 19 Sep 2013 Link to this post

    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.
  2. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 24 Sep 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jay
    Jay avatar
    59 posts
    Member since:
    Dec 2011

    Posted 24 Sep 2013 Link to this post

    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).
  5. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 27 Sep 2013 Link to this post

    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.
Back to Top