Modify jquery easyui combobox fuzzy filtering
filter:function (q,row){
var opts=$(this).combobox("options");
//return row[opts.textField].indexOf(q)==0;//
return row[opts.textField].indexOf(q)>-1;//Change the head position matching to any matching
},formatter:function(row){
var opts =$(this).combobox("options");
return row[opts.textField];
},loader:function(_7c9,_7ca,_7cb){
var opts=$(this) .combobox("options");
if(!opts.url){
return false;
}
Modify the easyui combobox extension to select the first row by default
The combobox extension of easyui selects the first line by default. There is a crazy scholar on the Internet who has reprinted the code countless times, but that code is only for easyui1.2.6. I tried it and it didn’t work under 1.3.2, so I rewrote it myself. An extension method is as follows:
$.extend($. fn.combobox.methods, {
selectedIndex: function (jq, index) {
if (!index) {
index = 0;
}
$(jq).combobox({
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));
break; });
}
});
The example of calling method is as follows:
Copy code
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn