EasyUI Combobox组合框(模糊搜索、默认值绑定)

EasyUI Combobox组合框是个比较好用的前端组件,例如它支持本地搜索和远程搜索,这样就可以免去自己写模糊查询。基本使用方式如下:

<input id="cc" name="dept" value="aa">
$('#cc').combobox({
    url:'JsonData.ashx',
    valueField:'id', //表单值
    textField:'text', //表单文本
    mode:'local', //本地搜索
    onLoadSuccess: function () { //加载完成后,默认选中第一项
         var val = $(this).combobox("getData");
         for (var item in val[0]) {
             if (item == "id") {
                 $(this).combobox("select", val[0][item]);
             }
         }
     }
});
[{
    "id":1,
    "text":"text1"
},{
    "id":2,
    "text":"text2"
},{
    "id":3,
    "text":"text3",
    "selected":true
},{
    "id":4,
    "text":"text4"
},{
    "id":5,
    "text":"text5"
}]
posted @ 2017-07-15 21:51  Arlar  阅读(764)  评论(0编辑  收藏  举报