EasyUI Forum
May 22, 2024, 04:53:08 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: Remove text in combobox when no one match with the options  (Read 8461 times)
aswzen
Sr. Member
****
Posts: 287


Indonesian

aswzen
View Profile WWW Email
« on: June 30, 2014, 08:25:01 PM »

Help me stworthy or anyone...

How to make the text that i write in combobox disappear when there are no options that match with the params?

demo to edit: http://jsfiddle.net/FrEHv/123/

thanks in advance......
Logged

Regards,
Sigit

- Indonesian jEasyUI Facebook page : https://www.facebook.com/groups/jeasyuiid/
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: June 30, 2014, 11:55:04 PM »

If you are sure that the value does not exist in the data list and you wish to clear the text box, please call 'setText' method with an empty string after calling 'setValue' method.
Code:
$('#Region').combobox('setValue', '5').combobox('setText','');

Another alternative way is to extend a new validation type to check if the value exists in the data list.
Code:
$.extend($.fn.validatebox.defaults.rules,{
       inList:{
              validator:function(value,param){
                     var c = $(param[0]);
                     var opts = c.combobox('options');
                     var data = c.combobox('getData');
                     var exists = false;
                     for(var i=0; i<data.length; i++){
                            if (value == data[i][opts.textField]){
                                   exists = true;
                                   break;
                            }
                     }
                     return exists;
              },
              message:'invalid value.'
       }
});
$(function(){
       $('#cc').combobox({
              required:true,
              validType:'inList["#cc"]'
       })
});

Logged
aswzen
Sr. Member
****
Posts: 287


Indonesian

aswzen
View Profile WWW Email
« Reply #2 on: August 28, 2014, 04:47:00 AM »

hmm..not working...
« Last Edit: March 11, 2015, 09:05:42 PM by aswzen » Logged

Regards,
Sigit

- Indonesian jEasyUI Facebook page : https://www.facebook.com/groups/jeasyuiid/
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!