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

List items appear with no margin on left

8 Answers 165 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Reid
Top achievements
Rank 2
Reid asked on 21 Mar 2018, 03:23 PM

When I drop down a dropdown list (DropDownListFor) , it's items are not margined and are truncating to the left.  Can anyone suggest a style to override or a way to set this? 

Thanks

8 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 26 Mar 2018, 08:50 AM
Hello Reid,

I am attaching an ASP.NET Core solution, where a similar scenario to the one described is demonstrated (DropDownList with large text items.) You will notice that although the DropDownList has a width of 200px, the popup list does not wrap the item labels on new lines.

To achieve the desired result, the DropDownList's AutoWidth option is used:
@(Html.Kendo().DropDownList()
.Name("news")
.DataTextField("Text")
.DataValueField("Value")
.AutoWidth(true)
.BindTo(new List<SelectListItem>() {
 new SelectListItem() {
 Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. ",
 Value = "1"
 },
 new SelectListItem() {
 Text = "Praesent sodales fermentum turpis ac tempor",
 Value = "2"
 },
 new SelectListItem() {
 Text = "Nullam semper est vel molestie viverra",
 Value = "3"
 }
})
  .Value("1")
.HtmlAttributes(new { style = "width: 200px" })
)


Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Reid
Top achievements
Rank 2
answered on 26 Mar 2018, 02:42 PM

Thank you roe replying.  I put the code in please and see no change, the items in the list are still in need of a margin on the left.

Any styles here to override?

0
Reid
Top achievements
Rank 2
answered on 26 Mar 2018, 02:42 PM
I forgot to mention that the control is a DropDownListFor<>/
0
Dimitar
Telerik team
answered on 27 Mar 2018, 02:29 PM
Hello Reid,

I assume that the issue is related to project specific styling. Therefore, may I ask you to update the solution that I have sent with my previous reply, so that the issue faced is reproduced and then attach it here as a .zip archive?

In the mean time you could try to pin-down the exact cause of the issue by commenting the stylesheets that are loaded on the current page. In addition to this, the browser DOM inspector could be used to check which styles are overriding the Kendo theme that is currently loaded in the project. 

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Reid
Top achievements
Rank 2
answered on 28 Mar 2018, 04:28 PM
Ok I will investigate it that way but is there not a factory style that exists for the drop down items that I could override in this template ?
0
Accepted
Dimitar
Telerik team
answered on 02 Apr 2018, 11:32 AM
Hello Reid,

You could try overriding the default styling to achieve a similar effect to the AutoWidth property as follows:
<style> 
.k-list-container {
  white-space: nowrap !important;
  width: auto !important;
}
</style>

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Reid
Top achievements
Rank 2
answered on 18 Apr 2018, 01:05 PM

Hi Dimitar,

I have decided to use the Bootstrap Select and have got it working fine.   It does seem to me that the Kendo Drop Down does not have the incremental search built in other that the first char typed.  Whereas the Bootstrap SelectList will show what you have typed in a search box as well as using a "contains" style so that items in the list that contain that pattern are displayed.  Many other configurable options as well.

 

Thanks

 

0
Dimitar
Telerik team
answered on 23 Apr 2018, 06:55 AM
Hi Reid,

I am glad to hear that you have managed to achieve the desired result.

Concerning the search functionality, the Kendo UI DropDownList has a built in filtering, which allows the user to choose from startswith, endswith and contains types. Those can be configured with the HtmlHelper as follows:
@(Html.Kendo().DropDownList()
  .Name("products")
  .DataTextField("ProductName")
  .DataValueField("ProductID")
  .HtmlAttributes(new { style = "width:100%" })
  .Filter(FilterType.Contains)
)

In case the filtering functionality needs to be customized further, the widget also provides the ServerFiltering options, which forces the filtering implementation to the remote service, thus allowing the user to have full control over the returned results (e.g filter by multiple fields). An example implementation of Kendo UI DropDownList with server filtering can be observed on the following ASP.NET Core Demo.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
DropDownList
Asked by
Reid
Top achievements
Rank 2
Answers by
Dimitar
Telerik team
Reid
Top achievements
Rank 2
Share this question
or