EasyUI Forum
May 01, 2024, 11:24:07 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 not select value while reading text from barcode  (Read 5653 times)
patana
Jr. Member
**
Posts: 50


View Profile
« on: December 31, 2019, 02:35:10 AM »

I found the combobox not select the value when i use barcode to enter; suddenly it clear the value.
And also happend on quickly pasted data and press enterkey.
Anyone can help?
Logged
patana
Jr. Member
**
Posts: 50


View Profile
« Reply #1 on: March 05, 2020, 07:42:43 AM »

Hello Admin, Can you help?
Logged
Aod47
Jr. Member
**
Posts: 83


View Profile
« Reply #2 on: March 06, 2020, 07:27:29 AM »

Could you paste your code?
Logged
patana
Jr. Member
**
Posts: 50


View Profile
« Reply #3 on: March 08, 2020, 08:45:49 PM »

$('#combo_id').combobox({                                       
                    onSelect: function(record){                       
                        alert('onSelect'+record.text);
                    }
});

In case of copy/paste and press key enter very fast, it's not work.
The same as using Barcode reader to input in the combobox.
« Last Edit: March 08, 2020, 08:50:46 PM by patana » Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #4 on: March 12, 2020, 12:36:39 AM »

Please try to override the 'query' and 'enter' key handlers to let the combobox component accept the inputing value quickly.
Code:
$('...').combobox({
url: ...,
valueField: 'id',
textField: 'text',
onSelect: function(row){
console.log(row)
},
keyHandler: $.extend({}, $.fn.combobox.defaults.keyHandler, {
query: function(q){
q = $.trim(q);
var t = $(this);
var opts = t.combobox('options');
var panel = t.combobox('panel');
var data = t.data('combobox').data;
var item = $.easyui.getArrayItem(data, opts.textField, q);
if (item){
t.combobox('select', item[opts.valueField]);
}
panel.panel('close')
},
enter: function(e){
var t = $(this);
t.combobox('hidePanel');
}
})
})
Logged
patana
Jr. Member
**
Posts: 50


View Profile
« Reply #5 on: March 12, 2020, 09:08:13 PM »

It seems not working with Enter key.
It is just fire onSelect when the input data matched in the list.
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #6 on: March 12, 2020, 11:27:12 PM »

Yes, it should match the data list. You can modify the 'query' code to fit your requirement.
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!