How to Get Dropdown's Selected Item's text in Kendo UI?

后端 未结 7 840
遥遥无期
遥遥无期 2021-02-05 02:05

I am using Kendo UI Controls. I want to get the selected text of the dropdown list in jquery. I have used this syntax :

 $(\"#ddl\").data(\"kendoDropDownList\")         


        
7条回答
  •  情深已故
    2021-02-05 02:39

    When a value is selected from a Dropdownlist in select event the selected value is available as following ,

    @(Html.Kendo().DropDownList()
                  .Name("booksDropDown")
                  .HtmlAttributes(new { style = "width:37%" })
                  .DataTextField("BookName")
                  .DataValueField("BookId")
                  .Events(x => x.Select("onSelectBookValue"))
                  .DataSource(datasource => datasource.Read(action => action.Action("ReadBookDropDow", "PlanningBook").Type(HttpVerbs.Get)))
                  .OptionLabel("Select"))
    

    Javascript function like following ,

      function onSelectBookValue(e) {    
    
                    var dataItem = this.dataItem(e.item.index());
                    var bookId = dataItem.BookId; // value of the dropdown
                    var bookName = dataItem.BookName; // text of the dropdown
                   //other user code
    }
    

    I believe this will help someone.

    Thanks

提交回复
热议问题