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

Reseting DropDownList Selection

1 Answer 71 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Syed
Top achievements
Rank 1
Syed asked on 30 Sep 2013, 02:29 PM
Hi,

I am using KendoUI version Q2 2012.
I have added a drpdownlist. I set its SelectedIndex to -1.But when I open a dropdown list it is selecting 0 index by default.
I want to reset selection after every selection.
Following is my code:

@(Html.Kendo().DropDownList()
                                  .Name("BorderWidth")
                                  .HtmlAttributes(new { style = "width: 0px;float:left;" })
                                  .DataTextField("Text")
                                  .DataValueField("Value")
                                  .SelectedIndex(-1)
                                  .Height(150)
                                          .Events(events => events
                                                      .Close("borderWidthChange")
                                                 )
                                  .BindTo(new List<SelectListItem>() {
                                      new SelectListItem() {
                                        Text = "1pt", Value = "1"   
                                      },
                                       new SelectListItem() {
                                        Text = "2pt", Value = "2"   
                                      },
                                       new SelectListItem() {
                                        Text = "3pt", Value = "3"   
                                      },
                                       new SelectListItem() {
                                        Text = "4pt", Value = "4"   
                                      },
                                       new SelectListItem() {
                                        Text = "5pt", Value = "5"   
                                      },
                                       new SelectListItem() {
                                        Text = "6pt", Value = "6"   
                                      }
                                  })
                                
.Template("${ data.Text } " + "<img src=\"" +
Url.Content("~/Content/Images/Line/") + "${data.Text}.png\" />")

                            )

Kindly help.

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 02 Oct 2013, 07:25 AM
Hello Syed,

Basically you can use the client API of the DropDownList to change the selection when it is needed. To do so I can suggest you to use either the select or the change event in combination with the select method.

Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
DropDownList
Asked by
Syed
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or