Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set kendo ui dropdownlist width

I would like to use a kendo drop-down list, which has a fixed size since is constrained by other fields in the page, but when it shows the drop-down items of the list, the drop-down 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 drop-down list properties set through jQuery?

like image 926
cortomaltese_marcof Avatar asked May 31 '13 11:05

cortomaltese_marcof


People also ask

What is dropdown UI in Kendo UI?

The DropDown UI component is a drop-down menu in which the user can select one element from the list of elements. When the user selected one element, the dropdown state is set to the element value. Kendo provided a beautiful drop-down UI element. Kendo UI is rich in UX experience the following examples are based on the kendo UI JQuery framework.

How to set kendodropdownlist to take up the full width?

you will initiate the kendoDropDownList using jQuery as follows: Now, to set this controller to take up the full width, what you have to do, is to set the width of the select element to 100%, or whatever is your desire. e.g.: If the id of you DropDownList is my-dropdown then you should write:

How to construct remote data source for kendo grid dropdownlist?

GetCategories () Action is used to return a datasource for the dropdownlist. I am going to use the below API response to construct my remote data source for Kendo Grid: Type - GET. Test the APIs using POSTMAN. The below API response is used to build datasource for drop-down list in Grid. Test the APIs using POSTMAN. Create a new HTML page.

How to add a custom editor in kendo grid?

Now, let’s add a custom editor which is a dropdown list in the Kendo Grid using editor attribute in column definition of Kendo Grid. categoryDropDownEditor editor function is used to load the datasource for Kendo dropdownlist.


1 Answers

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);
like image 193
OnaBai Avatar answered Sep 21 '22 17:09

OnaBai