首页 新闻 赞助 找找看

easyui combogird 模糊查询

0
悬赏园豆:5 [待解决问题]

如图 输入益阳匹配所有选项开头为益阳的选项

喜葵的主页 喜葵 | 初学一级 | 园豆:197
提问于:2019-07-04 16:55

combogrid没有模糊查询功能,可以自己手写一个,代码在下面,你可以参考下

兰茵 4年前
< >
分享
所有回答(2)
1

默认好像支持英语的智能筛选

大志若愚 | 园豆:2138 (老鸟四级) | 2019-07-04 18:39

试过了,改了easyui js文件中的keyup 但是还是没有达到想要的效果

支持(0) 反对(0) 喜葵 | 园豆:197 (初学一级) | 2019-07-06 10:33
0

<input class="c_search_box easyui-combogrid"type="text" id="txtCode" name="txtCode"
style="width: 200px;" />

第一步:定义全局变量
var wireRod;;
第二步:初始化加载下拉框值,并向全局变量 wireRod 赋值
$.ajax({
url: "/GatesManage/GetPublicVessels",//
type: "post",
dataType: "json",
success: function (data) {
debugger;
wireRod = data.rows;
}
});

第三步:定义下拉框方法,并其在 $(function () { });中初始化
function txtCode() {
$("#txtCode").combogrid({
editable: true,
required: false,
panelWidth: 190,
idField: 'VSL_CD',
textField: 'VSL_CNAME',
mode: 'remote',
//url: '/GatesManage/GetPublicVessels',
columns: [[
{ field: 'VSL_CD', title: '船代码', width: 60, hidden: true },
{ field: 'VSL_CNAME', title: '船名', width: 120 }
]],
keyHandler: {
up: function () {

            },
            down: function () { },
            enter: function () {
                //获取输入文本
                var VSL_CD = $.trim($('#txtCode').combogrid('getText'));
                //模糊查询匹配
                doSearch(VSL_CD, wireRod, ['VSL_CD', 'VSL_CNAME'], $(this));
            },
            query: function (q) {
                return false;
            }
        },
        //向下拉框加载至
        onShowPanel: function () {
            $(this).combogrid('grid').datagrid('loadData', wireRod);
        },
        fitColumns: false,
        onSelect: function (rowIndex, rowData) { Voyage(rowData.VSL_CD.toUpperCase()); }

    });
}

第四步:定义模糊拣选的方法
参数定义:q:输入文本
data:下拉框数据集
searchList:检索的内容
ele:控件本身($("#textCode"))
//前端模糊查询
function doSearch(q, data, searchList, ele) {
debugger;
ele.combogrid('grid').datagrid('loadData', []);
if (q == "") {
ele.combogrid('grid').datagrid('loadData', data);
return;
}
var rows = [];
$.each(data, function (i, obj) {
debugger;
for (var p in searchList) {
var v = obj[searchList[p]];

            if (!!v && v.toString().indexOf(q) >= 0) {
                rows.push(obj);
                break;
            }
        }
    });
    if (rows.length == 0) {
        ele.combogrid('grid').datagrid('loadData', []);
        return;
    }
    ele.combogrid('grid').datagrid('loadData', rows);
}
兰茵 | 园豆:458 (菜鸟二级) | 2019-07-29 17:09
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册