Kendo combobox.value(x)无法正常工作 [英] Kendo combobox.value(x) not working correctly

查看:103
本文介绍了Kendo combobox.value(x)无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试动态设置剑道组合框的值,但是当尝试执行以下操作时:

I'm trying to set value of kendo combobox dynamically, but when trying like:

var lvl1 = $("#level1Id").data("kendoComboBox");                        
var lvl2 = $("#level2Id").data("kendoComboBox");

var l2value = lvl2.value(); // save value for later use
... // do something that includes changing lvl2.value 
lvl2.value(l2value.toString()); // set lvl2.value back to previous

组合框值设置为代码"字段-例如-2,而不是值/文本"字段-"l2value代码的对应值".我了解到,value(x)带有字符串参数,因此我尝试了不同的转换方法(int-> string),但是没有运气.我在这里想念什么吗?动态设置此组合框值对我来说至关重要,因此将不胜感激.

the combobox value sets to "Code" field - for example - 2, instead of "Value/Text" field - "corresponding value of l2value code". I understand, that value(x) takes string parameter, so I've tried different conversion methods (int->string), but no luck. Am I missing something here? Setting this combobox value dynamically is essential for me, so any help would be appreciated.

我将在第二次设置值之前更改组合框过滤器.可能是这里的原因吗?

I'm changing the combobox filter just before setting value the second time. Could that be the reason here?

推荐答案

看看这个小提琴: http://jsfiddle.net/pvanhouten/qb8rD/1/.我试图说明如何获取当前选定的文本(苹果)和选定的值(1).您也可以在文本输入中键入一个值以设置组合框的选定值.如果键入apple,它将从组合框中选择apple条目.如果您键入的内容不在组合框列表中,则会将组合框的值设置为该值,并且当前所选项目的ID和文本都将是您键入的值.这是否有帮助根本没有?

Take a look at this fiddle: http://jsfiddle.net/pvanhouten/qb8rD/1/. I tried to show how you can get both the currently selected text (apple) and the selected value (1). You can also type a value into the text input to set the selected value of the combo box. If you type in apple, it will select the apple entry from the combo box. If you type in something that isn't in the combo box list, it will set the value of the combo box to that value and both the id and text for the currently selected item will be the value that you type in. Does that help at all?

这篇关于Kendo combobox.value(x)无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆