Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KendoUI Set width of dropdownlist

I'm looking for the best way to set the width of the KendoUI dropdownlist - via the Kendo HTML Helper.

@(Html.Kendo().DropDownList()
    .Name("ddlAccount")
    .DataTextField("Name")
    .DataValueField("Id")
    //This doesn't work, it styles the hidden input instead of the ddl
    .HtmlAttributes(new {style="width:200px;"})
)

I'm setting the width of the DropDownList, but notice in the generated HTML, the width of 200 pixels is set on a hidden text input, not the dropdownlist:

<span aria-busy="false" aria-readonly="false" aria-disabled="false" aria-owns="ddlAccount_listbox" tabindex="0" aria-expanded="false" aria-haspopup="true" role="listbox" class="k-widget k-dropdown k-header styled_select" style="" unselectable="on" aria-activedescendant="ddlAccount_option_selected">

<span class="k-dropdown-wrap k-state-default">
    <span class="k-input">Choice One</span>
    <span class="k-select">
        <span class="k-icon k-i-arrow-s">select</span>
    </span>
</span>
<input id="ddlAccount" name="ddlAccount" style="width: 200px; display: none;" type="text" data-role="dropdownlist">

...So the resulting DropDownList still scrolls both horizontally and vertically, which I don't want.

like image 372
DShultz Avatar asked Apr 29 '13 17:04

DShultz


2 Answers

@Html.Kendo().DropDownList().HtmlAttributes(new { style = "width:300px" }) on server side work for me and documented on http://docs.kendoui.com/ . May be not so long.

like image 161
Andrew Veriga Avatar answered Sep 25 '22 01:09

Andrew Veriga


With js, from the Kendo site:

// get reference to the DropDownList
var dropdownlist = $("#size").data("kendoDropDownList");
// set width of the DropDownList
dropdownlist.list.width(500);

JsFiddle

like image 34
Maess Avatar answered Sep 25 '22 01:09

Maess