This is a migrated thread and some comments may be shown as answers.

Issue with setting combobox selected value via JQuery $('#select').val('new value')

1 Answer 1173 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Linh
Top achievements
Rank 1
Linh asked on 14 Sep 2012, 06:16 AM
Hello,
Anyone come across this issue where the combobox widget does not display the selected item when using JQuery.val to set selected value.
Steps to reproduce:
- Go to to the demo page: http://demos.kendoui.com/web/combobox/index.html
- Open the Firebug console or similar.
- Enter the following:
 $('#select').data('kendoComboBox').value() --> outputs the current value: 'X-Small'
 $('#select').val() --> Also outputs the same
 $('#select').val('Small')

- Notice that the widget still displays 'X-Small', but both  $('#select').data('kendoComboBox').value()  and $('#select').val()  return 'Small'

Thanks.




1 Answer, 1 is accepted

Sort by
0
Nohinn
Top achievements
Rank 1
answered on 14 Sep 2012, 08:10 AM
The combobox widget builds up a new input field (the one you see), and the one you used ('#select') gets hidden.

So when you use $('#select').val('whatever') you're just setting the value to the hidden input.
The combobox value() function gets this hidden input value, but to make it show too the correct value you should set your new value through this value function.

$('#select').data('kendoComboBox').value("Small");
 
Tags
ComboBox
Asked by
Linh
Top achievements
Rank 1
Answers by
Nohinn
Top achievements
Rank 1
Share this question
or