DescriptionWhen DropDownList is set with a PopupWidth and if the text value is longer than the given width, then the text will be wrapped inside the popup element. To prevent DropDownList items text wrapping and get horizontal scroller in popup element, you can set the CSS style “white-space” value as “no-wrap” for the DropDownList items. SolutionDefine a DropDownList control and bind create event for it. In the create event handler, get the DropDownList object and set the CSS “white-space” as “no-wrap” for all list elements inside the DropDownList. This will prevent the text wrap of DropDownList items. To get the horiziontal Scroller for the popup, set the popup list wrapped width for the Scroller object and refresh() the Scroller. Refer the following code block, HTML<!-- Header section with required references for rendering JavaScript control--> <div>Select a State</div> <input type="text" id="stateList" /> JavaScript$(function () { // declaration var states = [ { index: "s1", countryName: "Alabama" }, { index: "s2", countryName: "Alaska" }, { index: "s3", countryName: "Arizona" }, { index: "s4", countryName: "Arkansas" }, { index: "s5", countryName: "California" }, { index: "s6", countryName: "Colorado" }, { index: "s7", countryName: "Connecticut" }, { index: "s8", countryName: "Delaware" }, { index: "s9", countryName: "Florida" }, { index: "s10", countryName: "Georgia" }, { index: "s11", countryName: "Hawaii" }, { index: "s12", countryName: "Idaho" }, { index: "s13", countryName: "Illinois" }, { index: "s14", countryName: "Indiana" }, { index: "s15", countryName: "Iowa" }, { index: "s16", countryName: "Kansas" }, { index: "s17", countryName: "Kentucky" }, { index: "s18", countryName: "Louisiana" }, { index: "s19", countryName: "Maine" }, { index: "s20", countryName: "Maryland" }, { index: "s21", countryName: "Massachusetts" }, { index: "s22", countryName: "Michigan" }, { index: "s23", countryName: "Montana" }, { index: "s24", countryName: "New Mexico" }, { index: "25", countryName: "New York" }, { index: "26", countryName: "North Carolina" }, { index: "s27", countryName: "Nevada" }, { index: "s28", countryName: "New Jersey" }, { index: "s29", countryName: "Pennsylvania" }, { index: "s30", countryName: "Ohio" }, { index: "s31", countryName: "Oklahoma" }, { index: "s32", countryName: "Oregon" }, { index: "s33", countryName: "Rhode Island" }, { index: "s34", countryName: "South Carolina" }, { index: "s35", countryName: "South Dakota" }, { index: "s36", countryName: "Tennessee" }, { index: "s37", countryName: "Texas" }, { index: "s38", countryName: "Utah" }, { index: "s39", countryName: "Vermont" }, { index: "s40", countryName: "Virginia" }, { index: "s41", countryName: "Washington" }, { index: "s42", countryName: "West Virginia" }, { index: "s43", countryName: "Wisconsin" }, { index: "s44", countryName: "Wyoming" } ]; $('#stateList').ejDropDownList({ width: 100, popupWidth:100, dataSource: states, fields: { id: "index", value: "index", text: "countryName" }, create: function (args) { var dropDownObj = $("#stateList").data("ejDropDownList"); dropDownObj.ultag.children('li').css({ "white-space": "nowrap" }); //To display the horizontal scroller dropDownObj.scrollerObj.model.width = dropDownObj.popupListWrapper.outerWidth(); dropDownObj.scrollerObj.refresh(); } }); }); Output DropDownList items without text wrap, Figure 1: Popup element with a horizontal Scroller |
This page will automatically be redirected to the sign-in page in 10 seconds.