easyUI提供了一个数据选择框 comboselector
<input name="brand_name" id="brand_name" value="" class="easyui-validatebox" data-options="required:false, validType:'', prompt: ''">
$("#brand_name").comboselector($.extend({},window.brandList)); //会在input标签后面加上选择框按钮
window.brandList={
topMost:false,
extToolbar:true,
toolbar:[
"品牌名",
{id:'searchtext',type:'textbox',options:{'width':80}},
{type:"button",options:{
text:"查询",iconCls:"icon-search",handler:function(toolbar){
alert(toolbar);
var bar=$(toolbar),searchtext=bar.find("#searchtext").val(),
dg=bar.closest(".grid-selector-container").find(".grid-selector");
$.easyui.messager.show("查询 品牌名:{0}".format(searchtext));
dg.datagrid("load", { name : searchtext});
}
}
}
],
singleSelect:true,
//multiple:false,
method:"get",
url:'${ctx}/car/brand/json',
idField:'id',
textField:'name',
autoShowPanel:false,
remoteSort:false,
pagination:true,
columns:[[
{field:"ck",checkbox:true},
{field:"id",title:'ID',80},
{field:"name",title:'品牌名',80}
]],
onEnter: function (val) { $.easyui.messager.show(String(val.map(function (val) { return val.ID; }))); },
onChange: function (newValue,oldValue) {}
}