This is a migrated thread and some comments may be shown as answers.

Autofit to content

3 Answers 342 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Iron
Iron
Veteran
Dan asked on 06 Nov 2020, 06:31 AM
Can the listbox be made to autofit its content?

3 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 06 Nov 2020, 01:47 PM

Hello Dan,

The ListBox is designed to adds a vertical scrollbar when the height of the items exceeds its own height so they are still fit within the widget. The following Dojo demo demonstrated this behavior.

Let me know if this clarifies the question or if the inquiry is different please share more details so I can advise further.

Regards,
Nikolay
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Dan
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 06 Nov 2020, 02:23 PM

Hi Nikolay,

That is not what I meant. I have a list box with 7 or 8 items that have a short text. And I want for the listbox to have the width that will fit those items. The items are translatable so in some languages the text might be 100px and in some languages the text might be 150px so I need for the listbox to have the width auto. 

Also I should mention that the height should be fixed so a scrollbar might appear.

0
Nikolay
Telerik team
answered on 10 Nov 2020, 12:44 PM

Hi Dan,

Thank you for clarifying the scenario.

In this case, the ListBox can accept a fixed height and auto width with the following CSS:

<style>
    #example .k-listbox {
        width: auto;
        height: 200px;
    } 
</style>

Please take a look at the following Doj and let me know if this is what you are looking for:

Regards,
Nikolay
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
ListBox
Asked by
Dan
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Nikolay
Telerik team
Dan
Top achievements
Rank 1
Iron
Iron
Veteran
Share this question
or