EasyUI Forum
April 29, 2024, 11:04:11 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: clear combobox  (Read 23726 times)
azizkhani
Newbie
*
Posts: 37


View Profile Email
« on: April 26, 2015, 09:07:54 AM »

i have a combobox that editable:false,required:false


user select one item and then want to clear selected item how do it HuhHuhHuhHuh?
 Huh Huh Huh Huh
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: April 26, 2015, 06:20:30 PM »

Please call 'unselect' method to unselect a item.
Code:
var value = ...  // the item value to be selected
$('#cc').combobox('unselect', value);
Logged
azizkhani
Newbie
*
Posts: 37


View Profile Email
« Reply #2 on: April 27, 2015, 09:11:15 AM »

Please call 'unselect' method to unselect a item.
Code:
var value = ...  // the item value to be selected
$('#cc').combobox('unselect', value);


 Grin Grin Grin Grin
i asked how user(not developer) can do it?
for solve this problem i added a button that user click it and then unselect combo ? this is good idea!!!!!
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: April 27, 2015, 05:23:30 PM »

You can add an icon to the right of input box. When clicking the icon, call 'clear' or 'unselect' methods to unselect the values.
Code:
$('#cc').combobox({
icons:[{
iconCls:'icon-clear',
handler:function(e){
$(e.data.target).combobox('clear');
}
}]
})
Logged
jjosotoro
Newbie
*
Posts: 4


View Profile
« Reply #4 on: May 12, 2015, 06:51:34 AM »

hello

I dont know if this may help, but why dont you use the keyup event to detect the delete key on the combobox and call the 'unselect' event acordingly.

Code:
$('#cc').combobox({
inputEvents: $.extend({}, $.fn.combo.defaults.inputEvents, {
keyup:function(e){
  if(e.keyCode == 46){
                    var value = $('#cc').combobox('getText');  // the item value to be selected
                    $('#cc').combobox('unselect', value);
  }

}
})
})

regards
Logged
bvn
Newbie
*
Posts: 13


View Profile
« Reply #5 on: January 25, 2019, 11:55:49 AM »

I always get: "TypeError: $.data(...) is undefined" when trying to clear or unselect item in combobox (combotree in my case).

Code:
<input id="parent_id" class="easyui-combotree form-control" name="parent_id" data-options="prompt:'<?=__('Select Parent')?>'">

var parent = $('#parent_id').combotree({
url: baseUrl+'admin/pagesrest/pages_combotree',
inputEvents: $.extend({}, $.fn.combo.defaults.inputEvents, {
keyup:function(e){
 if(e.keyCode == 46 || e.keyCode == 8){
var value = $('#parent_id').combobox('getText');  // the item value to be selected
$('#parent_id').combobox('unselect', value);
 }
}
}),
icons:[{
iconCls: 'icon-clear',
handler:function(e){
parent.combobox('clear');
}
}]
});
Logged
bvn
Newbie
*
Posts: 13


View Profile
« Reply #6 on: January 25, 2019, 12:03:03 PM »

Oh, it's my bug... I used combotree, but in code (copy-pasted) using combobox... that's a reason of my problem. Sorry.
Logged
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!