jquery easyUI 下拉显示提示数据
$(document).ready(function(){
init();
});
functioninit(){
$('#cjoiners').combobox({
onChange:function(newValue,oldValue){
loadOnPaeuser(newValue,oldValue);
},
onSelect:function(record){
//$("#cjoiners").attr("value",record.name);
$('#cjoiners').combobox('select',record.name);
},
valueField:'id',
textField:'name'
});
}
functionloadOnPaeuser(n,o){
n=jQuery.trim(n);
o=jQuery.trim(o);
if(n!=""){//&&n!=o
varnametemp=n;
//$("#cjoiners").attr("value",n);
url="/cms/custservice/ajax_cmFind_findPaesByName.action?name="+encodeURI(encodeURI(nametemp));
$('#cjoiners').combobox('reload',url);
//$("#cjoiners").attr("textField",n);
}
}
============================================================================
后台java提供数据代码:
publicListfindSomeDataByName(Stringname){
StringBuffersql=newStringBuffer();
sql.append("selectdistinctNAME,IDfromPERSONAL_AND_EXECUTIVE");
sql.append("where");
sql.append("namelike'%"+name+"%'");
finalListlist=newArrayList();
getJdbcTemplate().query(sql.toString(),newObject[]{},
newRowCallbackHandler(){
publicvoidprocessRow(ResultSetres)throwsSQLException{
PersonalAndExecutivepersonalAndExecutive=newPersonalAndExecutive();
personalAndExecutive.setId(Integer.valueOf(res.getString("id")));
personalAndExecutive.setName(res.getString("NAME"));
list.add(personalAndExecutive);
}
});
returnlist;
}