Heim  >  Artikel  >  Web-Frontend  >  jquery easyui combobox模糊过滤(示例代码)_jquery

jquery easyui combobox模糊过滤(示例代码)_jquery

WBOY
WBOYOriginal
2016-05-16 17:11:28953Durchsuche

修改jquery easyui combobox模糊过滤

复制代码 代码如下:

filter:function(q,row){
var opts=$(this).combobox("options");

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

return row[opts.textField].indexOf(q)>-1;//将从头位置匹配改为任意匹配
},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;
}

修改easyui combobox扩展可以默认选择第一行

easyui的combobox扩展默认选择第一行,网上有疯狂秀才的那个被转载了无数次的代码,但是那个只是针对easyui1.2.6的,试了一下在1.3.2下不行的,自己重新写了一个扩展方法如下:

复制代码 代码如下:

$.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                     if (i == index) {
                        $(jq).combobox('setValue', eval('data[index].' + opt.valueField));
                        break;
                    }
                }
            }
        });
    }
});

调用方法实例如下:
复制代码 代码如下:


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn