Home > Web Front-end > JS Tutorial > jquery easyui combobox fuzzy filtering (sample code)_jquery

jquery easyui combobox fuzzy filtering (sample code)_jquery

WBOY
Release: 2016-05-16 17:11:28
Original
999 people have browsed it

Modify jquery easyui combobox fuzzy filtering

Copy code The code is as follows:

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:

Copy the code The code 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
The code is as follows:


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template