EasyUI Forum

General Category => Bug Report => Topic started by: peter on October 29, 2017, 02:03:55 AM



Title: Bug in combobox with filter and onShowPanel
Post by: peter on October 29, 2017, 02:03:55 AM
I have set up a combobox as shown below.
The first time that the user presses a key in the combobox the following events happen:
 1. The filter is run on the current data in the combo box
 2. Once that is finished, the onShowPanel code is run. In this case it is a reload.
 3. The filter is NOT run on the reloaded data.

Shouldn't the filter be run on the reloaded data?

Peter



$(id).combobox({ 
   url:        url, 
   method:     'post',
   mode:       'local',
   valueField: valueField, 
   textField:  textField,
   editable:   true,
   required:   true,
   filter: function(query,row) {
       var opts = $(this).combobox('options');
       var valueInDropdown = row[opts.textField] ;
       return myTest(query, valueInDropdown) ;
   },
   onShowPanel: function() {
       $(id).combobox('reload') ;
   }
}) ;


Title: Re: Bug in combobox with filter and onShowPanel
Post by: stworthy on October 29, 2017, 08:36:29 PM
The 'reload' method reloads data from remote server. It does not trigger the 'filter' action. You should call the code below to filter data.
Code:
var q = 'filter value...';
var cc = $('#cc');
cc.combobox('options').keyHandler.query.call(cc[0], q);

You can also override the 'query' function to custom your filter logic.
Code:
$('#cc').combobox({
mode: 'local',
keyHandler: $.extend({}, $.fn.combobox.defaults.keyHandler, {
query: function(q, e){
//...
}
})
})