您的位置:首页 > 产品设计 > UI/UE

easyui combobox实现本地模糊查询

2016-10-20 10:12 591 查看
var _time_out = null;
$("#txt1").combobox({
valueField : "value",
textField : "text",
height : 32,
method : "get",
editable : true,
keyHandler : {
query : function (q) {
if (_time_out) {
clearTimeout(_time_out);
}
_time_out = setTimeout(function () {
var opts = $("#txt1").combobox('options');
var data = $("#txt1").combobox("getData");
var value = $("#txt1").combobox("textbox").val();
$.each(data, function (k, node) {
if (node[opts.textField].indexOf(value) >= 0) {
//$("#txt1").combobox("select",node[opts.valueField]);
//$("#txt1").combobox("setValue", node[opts.valueField]);
var item = $("#txt1").combobox("panel").panel("body").find("div").filter(function () {
return $(this).html() == node[opts.textField];
});
if (item) {
clearTimeout(_time_out);
_time_out = null;
$("#txt1").combobox("panel").panel("body").scrollTop(item.position().top);
$("#txt1").combobox("select", node[opts.valueField]);
return false;
}

}
})
clearTimeout(_time_out);
_time_out = null;
}, 500);
}
},
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: