设置kendo ui下拉列表宽度 [英] Set kendo ui dropdownlist width

查看:167
本文介绍了设置kendo ui下拉列表宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚使用kendo组件。对不起,如果问题可能看起来很愚蠢,但我无法弄明白答案。
我想使用kendo下拉列表,它具有固定大小,因为它被页面中的其他字段限制,但是当它显示列表的下拉列表项时,下拉区域应该调整到最大长度项目。显示项目的固定宽度排序,但下拉列表的自动宽度。
有些东西像
|我的选择| < - 页面上显示的固定宽度



|下一个选择|
|上一个选择| < - 下拉区域以选择另一个项目
| dummy |



这可能通过CSS或dropdownlist属性设置通过jquery?



非常感谢您的帮助



Marco

解决方案

您可以使用CSS或使用方法设置DropDown列表的宽度。



如果id你 DropDownList my-dropdown 那么你应该写:




  • 使用CSS



    #my-dropdown-list {
    width:auto!
    }




注意:我们附加了 -list 到原来的 id 。 !important很重要,因为您要覆盖原始宽度定义。




  • 使用方法



    $(#my-dropdown)。data(kendoDropDownList)。list.width(auto);




除了使用auto获得自动调整到文本的宽度,您可以使用固定宽度:

 #my-dropdown-list {
width:300px!important;
}

  $( #我-下拉)的数据( kendoDropDownList)list.width(300)。。 


I'm new in using kendo components. Sorry if the question might seem silly but I can't figure out the answer. I would like to use a kendo dropdownlist, which has a fixed size since is constrained by other fields in the page, but when it shows the dropdown items of the list, the dropdown area should resize to the maximum length of the items. Sort of fixed width for the item displayed, but auto width for the drop down list. Something like |my choice | <-- fixed width displayed on the page

|next choice | |previous choice | <-- dropdown area to select another item |dummy |

Is this possible through css or dropdownlist properties set through jquery ?

Thank you very much for your help

Marco

解决方案

You can set the width of a DropDown List both using a CSS or using a method.

If the id of you DropDownList is my-dropdown then you should write:

  • Using CSS

    #my-dropdown-list { width: auto !important; }

NOTE: We have appended -list to the original id. The "!important" is important since you want to overwrite original width definition.

  • Using a method

    $("#my-dropdown").data("kendoDropDownList").list.width("auto");

In addition to use "auto" for getting the width automatically adjusted to the text, you can use a fixed width:

#my-dropdown-list {
    width: 300px !important;
}

or

$("#my-dropdown").data("kendoDropDownList").list.width(300);

这篇关于设置kendo ui下拉列表宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆