The items in my drop down list are quite long - is there a way of wrapping the text in the options used within the dropdown list so that all the text can be displayed?
If so, is there also a way of indenting the "wrapped" lines (all except the first line)?
I was able to do this in chosen.js, but would I am using the telerik dropdown in this instance due to it's virtualisation capabilities.
4 Answers, 1 is accepted
To see an example of how the functionality you describe could be implemented, take a look at the following sample in our documentation.
Could you tell me a little bit more about your second requirement to indent the wrapped lines?
I hope this helps!
Thank you Eduardo.
I used the databound event to attach a class which I hoped would wrap the options. The problem I have is that there is an inline style of height:26px; - unticking this in DOM explorer gives the text more room but the wrapped text overlaps.
It is not enough to widen the field, as I can't widen the input any further, and this would cause problems with responsiveness - I prefer my applications to be adaptable to the screen they're being used on, and this system is due to be used on tablet screens by a significant amount of users. See the attachment for an example of what it is doing.
Here's my Razor C#:
I tried this without the ItemHeight on line 34, but the helper still applies an inline-styled height of 25px.
Here's my CSS:
I think I see the source of the issue, and why the virtualisation needs a height - it uses the height to then calculate a "translateY" style attribute for each li element. So if none is supplied, it still needs it's own internal default in order to correctly calculate the elements position.
Why is translateY used here? Is this for animation? Will turning off animations disable it? Or is it a subsequence of using virtualisation? Is this how it creates elements for the "Loading..." options it displays when waiting for data from the server?
Turning off virtualisation isn't an option - there are 2000+ options in this menu, which is why I thought virtualisation would be perfect for this situation.
the AutoComplete element may be one alternative. But will it also bring with it the height/translateY issue?
Any ideas or thoughts you have would be gratefully received.
The DropDownList items are not intended to be multi-line by design. Therefore, customizing their appearance can be achieved by using a template.
I am attaching a sample ASP.NET MVC solution, where a suggestion approach on how to handle the described scenario is demonstrated. To maintain the normal behavior of the widget, the Name of the item is shown as text, while its Description is shown as Tooltip:
Checkout the solution above in order to verify if this approach will satisfy your requirements.You can tweak it further with additional CSS and modifying the tooltip position. This provides a flexible way of displaying all of the relevant data from the server, while also maintaining the built-in Virtualization of the widget to improve the performance for loading large data sets.
Regarding the Virtualization technique - it utilizes a specific strategy for displaying the data in the widget. In the context of data, optimizing the performance is achieved by retrieving only a specific data page from the remote service instead of the whole data set. To further improve the performance, the DOM elements that are displaying the corresponding data chunk are being reused. The number of these DOM elements is determined by the height and itemHeight options. Once the number is calculated, the widget creates those elements and starts reusing them to display the current data source page. This is why, wrapping the items content in such scenario would require to take into consideration those implementation details and can cause undesired side effects.