Autosize dropdownlist

2 posts, 0 answers
  1. Steven
    Steven avatar
    84 posts
    Member since:
    Oct 2010

    Posted 05 Jul 2012 Link to this post

    I am trying to get the dropdownlist to auto size to the contents after an ajax load.   In the dataBound event I have the following code:

    if( isDefined( this.options.width )) {
        if( this.options.width === "auto" ) {
         var popup = this.control.popup.element;
         var width = popup.css("visibility","hidden").show().outerWidth();
         popup.hide().css("visibility","visible");
        } else {
         width = this.options.width;
        }
        this.control.wrapper.closest(".k-widget").width(width);
    }

    It seems to operate to some degree, but the problem is the outerWidth is not calculated properly and I am still getting wrapping on the items in the dropdown list.   

    Is this an issue with the calculation or am I doing this too soon (i.e. while it is still loading)?  

    Is there a better way?
    Is there a different event I should use?  (using this method in the change event does not work at all)

  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 10 Jul 2012 Link to this post

    Hi Steven,

    I would suggest you to use the Open event of the DropDownList - http://demos.kendoui.com/web/dropdownlist/events.html 

    I hope this helps.


    Regards,
    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top