Jquery easyui combobox fuzzy filter of sample code

  • 2020-03-30 00:39:16
  • OfStack

Fix jquery easyui combobox blur filtering

var opts=$(this).combobox("options"); 

//return row[opts.textField].indexOf(q)==0;// 

return row[opts.textField].indexOf(q)>-1;//Change the ab initio position match to an arbitrary match
var opts=$(this).combobox("options"); 
return row[opts.textField]; 
var opts=$(this).combobox("options"); 
return false; 

Modify the easyui combobox extension to select the first line by default

By default, the first line of easyui's combobox extension is selected. The code that has been reprinted for countless times is crazy on the Internet, but that is only for easyui1.2.6, tried to do it under 1.3.2, and wrote an extension method as follows:

$.extend($.fn.combobox.methods, { 
    selectedIndex: function (jq, index) { 
        if (!index) { 
            index = 0; 
            onLoadSuccess: function () { 
                var opt = $(jq).combobox('options'); 
                var data = $(jq).combobox('getData'); 

                for (var i = 0; i < data.length; i++) { 
                    if (i == index) { 
                        $(jq).combobox('setValue', eval('data[index].' + opt.valueField)); 

The example of the calling method is as follows:

<script type="text/javascript"> 
var currenturl = "om_taking.aspx"; 
        $(function () { 
                url: currenturl + "?act=loadDept", 
                valueField: 'DEPARTMENT_ID', 
                textField: 'DEPARTMENT_NAME'
            }).combobox('selectedIndex', 0); 

Related articles: