EasyUI Forum
April 30, 2024, 01:28:19 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: combobox setValue also sets text [Solved]  (Read 10437 times)
devnull
Sr. Member
****
Posts: 431


View Profile
« 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
« Last Edit: January 25, 2015, 06:56:30 PM by devnull » Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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);
Logged
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #2 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 ?
Logged

-- Licensed User --
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!