easyui combobox下拉效果 可输入 模糊查询




判断输入值在下拉列表是否存在
var nameStr ='';
$(document).ready(function(){

$('#customerId').combobox({
prompt:'请输入或选择客户名称',
url:'${rc.contextPath}/sale/findBusinessPartnerByName',
valueField:'id',
textField:'text' ,
onClick: function(node) {
attributeShow($("#customerId").combotree("getValue"));
},
filter: function(q, row){
var opts = $(this).combobox('options');
//return row[opts.textField].indexOf(q) == 0;
return row[opts.textField].indexOf(q)>-1;//将从头位置匹配改为任意匹配
},
onLoadSuccess: function(){
var partnerId = '${(saleOrder.partnerId)!}';
if(partnerId){
$('#customerId').combobox('setValue',partnerId);
}
},
onSelect: function(){
var partnerId = $("#customerId").combotree("getValue");
$("#business_partner_id").val(partnerId);
findBusinessPartnerContactByPartnerId(partnerId);
findSaleAddressByPartnerId(partnerId);
},
onChange: function(newValue, oldValue){
var v = $("#customerId").combotree("getText");
var arr = nameStr.split(',');
var index = $.inArray(v, arr);
if(index < 0 ){
$("#business_partner_id").val('');
}else{
$("#business_partner_id").val($("#customerId").combobox("getValue"));
}
},
formatter: function(row){
var opts = $(this).combobox('options');
nameStr += row[opts.textField] + "," ;
return row[opts.textField];
}
});

});

你可能感兴趣的:(java,其它)