Reputation: 1764
I am trying to get the selected value of Html.Kendo().ComboBoxFor() but I am unable to load that. PFB the code.
@Html.Label("From Descriptor")
</div>
<div class="editor-field">
@(
Html.Kendo().ComboBoxFor(m => m.desc)
.HtmlAttributes(new { @class = "form-control input-md" })
.BindTo((System.Collections.IEnumerable)ViewData["data"])
.DataValueField("Id")
.DataTextField("TimeDescriptor")
.Events(e => e.Select("onChangvalue"))
)
</div>
But when I try to get data in ready() function I am unable to get that, PFB.
var grid = $("#data_grid").data("desc");
Upvotes: 1
Views: 217
Reputation: 1118
Try the following:
HTML:
@Html.Label("From Descriptor")
</div>
<div class="editor-field">
@(
Html.Kendo().ComboBoxFor(m => m.desc)
.Name("ddl")
.HtmlAttributes(new { @class = "form-control input-md" })
.BindTo((System.Collections.IEnumerable)ViewData["data"])
.DataValueField("Id")
.DataTextField("TimeDescriptor")
.Events(e => e.Select("onChangvalue"))
)
</div>
Javascript:
var ddl1 = $("#ddl").data("kendoComboBox");
alert(ddl1.value);
Upvotes: 1