最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Kendo combobox.value(x) not working correctly - Stack Overflow

programmeradmin1浏览0评论

I'm trying to set value of kendo bobox 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

the bobox 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 bobox value dynamically is essential for me, so any help would be appreciated.

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

I'm trying to set value of kendo bobox 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

the bobox 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 bobox value dynamically is essential for me, so any help would be appreciated.

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

Share Improve this question edited Oct 5, 2012 at 14:37 andree asked Oct 5, 2012 at 14:05 andreeandree 3,2359 gold badges38 silver badges43 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

Take a look at this fiddle: http://jsfiddle/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 bo box. If you type in apple, it will select the apple entry from the bo box. If you type in something that isn't in the bo box list, it will set the value of the bo 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?

发布评论

评论列表(0)

  1. 暂无评论