(@_@;)我是程序猿,我编程,我快乐,知识改变命运,技术成就梦想   oh yeah!合作VX "w6668263" 联系Email:ye583025823@126.com

easyui combobox实现本地模糊查询

 

直接上代码

 

$("#combobox1").combobox({
    valueField : "value",
    textField : "text",
    height : 32,
    method : "get",
    editable : true,
    delay : 600, //最后一次输入事件与执行搜索之间的延迟间隔(执行自动完成功能的延迟间隔)
    keyHandler : {
        query : function (value) {
            if (value == '') {
                $("#combobox1").combobox("clear");
                return;
            }
            var opts = $("#combobox1").combobox('options');
            var data = $("#combobox1").combobox("getData");
            $.each(data, function (k, node) {
                //如果开启拼音搜索后台需要支持一个pinyin的字段。
                //if (node[opts.textField].indexOf(value) >= 0 || node['pinyin'].indexOf(value.toLocaleLowerCase()) >= 0) {
                if (node[opts.textField].indexOf(value) >= 0) {
                    //如果是单选就可以加上这句
                    $("#combobox1").combobox("clear");
                    $("#combobox1").combobox("select", node[opts.valueField]);
                    return false;
                }
            });
        }
    },
    data : [{
            "value" : "1001001",
            "text" : "泗水县"
        }, {
            "value" : "1001002",
            "text" : "嘉祥县"
        }, {
            "value" : "1001003",
            "text" : "市中区"
        }, {
            "value" : "1001004",
            "text" : "兖州市"
        }, {
            "value" : "1001005",
            "text" : "金乡县"
        }, {
            "value" : "1001006",
            "text" : "曲阜市"
        }, {
            "value" : "1001007",
            "text" : "梁山县"
        }, {
            "value" : "1001008",
            "text" : "微山县"
        }, {
            "value" : "1001009",
            "text" : "市辖区"
        }, {
            "value" : "10010010",
            "text" : "汶上县"
        }, {
            "value" : "10010011",
            "text" : "鱼台县"
        }, {
            "value" : "10010012",
            "text" : "任城区"
        }, {
            "value" : "10010013",
            "text" : "邹城市"
        }

    ]
});

 

 

 

技术交流QQ群:15129679

posted on 2016-10-20 10:12  一个草率的龙果果  阅读(5724)  评论(1编辑  收藏  举报

导航