EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: devnull on January 23, 2015, 06:21:52 PM



Title: combobox setValue also sets text [Solved]
Post by: devnull on January 23, 2015, 06:21:52 PM
Hi;

When I use the setValue() on a combobox() it also sets the text.

How can I ONLY set the value without changing the text ?

Thanks


Title: Re: combobox setValue also sets text
Post by: stworthy on January 24, 2015, 01:08:07 AM
You can retrieve the combobox's text first and then restore its text after calling 'setValue' method.
Code:
var cc = $('#cc');
var text = cc.combobox('getText');
cc.combobox('setValue', yourvalue');
cc.combobox('setText', text');  // restore the original text

Another way to set the value only is to call 'setValue' method of combo instead.
Code:
var cc = $('#cc');  // the combobox object
cc.combo('setValue', yourvalue);


Title: Re: combobox setValue also sets text [Solved]
Post by: devnull on January 25, 2015, 06:57:10 PM
Thanks, but why does setting the value also set the text, shouldn't it only set the value ?