EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: patana on December 31, 2019, 02:35:10 AM



Title: Combobox not select value while reading text from barcode
Post by: patana 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?


Title: Re: Combobox not select value while reading text from barcode
Post by: patana on March 05, 2020, 07:42:43 AM
Hello Admin, Can you help?


Title: Re: Combobox not select value while reading text from barcode
Post by: Aod47 on March 06, 2020, 07:27:29 AM
Could you paste your code?


Title: Re: Combobox not select value while reading text from barcode
Post by: patana 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.


Title: Re: Combobox not select value while reading text from barcode
Post by: jarry 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');
}
})
})


Title: Re: Combobox not select value while reading text from barcode
Post by: patana 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.


Title: Re: Combobox not select value while reading text from barcode
Post by: jarry 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.