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

Autosize dropdownlist

1 Answer 100 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 06 Jul 2012, 03:44 AM
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)

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 10 Jul 2012, 01:23 PM
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!
Tags
DropDownList
Asked by
Steven
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or