如何从剑道组合框中获得价值 [英] How to get value from kendo combobox
本文介绍了如何从剑道组合框中获得价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从kendo组合框值中获得收益?我总是对此感到不确定.我已经使用了这些变体,但是它们对我不起作用
How can I get from kendo combobox value? I always getting undefined on it.. I've used these variants, but they are not worked for me
var selected = $('#typesCombo').data('kendoComboBox').val();
var selected = $('#typesCombo').data('kendoComboBox').value();
var selected = $('#typesCombo').data('kendoComboBox');
并收到如下错误:无法读取未定义的属性'val'
这是我的代码:
JS:
$('#loadContainer').load("@Url.Action("Load", "Home")" + id);
var selected = $('#typesCombo').data('kendoComboBox').val();
if (selected == '') {
...
}
HTML:
@(Html.Kendo().ComboBoxFor(x => x.Types.Name).Name("typesCombo")
.DataTextField("Name")
.DataValueField("Id")
.HtmlAttributes(new { style = "width:100%", id = "typesCombo" })
.BindTo(Model.TypesList))
推荐答案
有很多方法可以获取小部件的选定值.如果您尝试在初始化后获得该值,并且没有选择的值(在
There are many ways to get the widget selected value. If you are trying to get the value after it initialization and it has no selected value(declared in the index
parameter) you will get an empty value. If you want to get the value when user changes it, you can use the select
event and get the value like this:
$("#typesCombo").data('kendoComboBox').value(); // The selected value itself
$("#typesCombo").data('kendoComboBox').dataItem(); // The selected entire dataItem object
$("#typesCombo").val(); // Only if the target element is an input element
这篇关于如何从剑道组合框中获得价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文