easyui combobox可编辑的情况下,只能首字母开始过滤的问题选项

esayui中的combobox下拉列表在可编辑的情况下可以输入内容来过滤下拉框的选项,而1.4.2版本只能在从首字母开始过滤例如其中一个选项是"test",

只能输入"te"过滤才"te"开头的选项,而输入"st"则不行。这是因为jQuery.easyui.min.js中的filter定义的问题,打开jquery.easyui.min.js找到如下:

filter:function(q,row){  
var opts=$(this).combobox("options");  
return row[opts.textField].toLowerCase().indexOf(q.toLowerCase())==0;  
}  
 

意思是从输入值的索引的与combobox下拉框文本第一位相等时才显示;
修改为:

return row[opts.textField].toLowerCase().indexOf(q.toLowerCase())<span style="color:#ff6666;">>=</span>0;  
 

即可;意思是输入值只要在combobox下拉框文本任意位置匹配都显示。

该问题在easyui1.4.5版本中已经修复。

HTML文件:

<select id="aucBrandNo" class="easyui-combobox" name="aucBrandNo" style=" 160px;"
      data-options="required:true,onHidePanel:function(){validateComboboxInputValue(this)}">
</select>

JS文件:

$('#aucBrandNo').combobox({
        filter: function(q, row){
            var opts = $(this).combobox('options');
            return row[opts.textField].indexOf(q) == 0;
        }

    });

转载自:http://blog.csdn.net/zljava2009/article/details/52797129

原文地址:https://www.cnblogs.com/mr-wuxiansheng/p/7277172.html