jquery easyUI 下拉显示提示数据
$(document).ready(function (){
init();
});
function init(){
$('#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'
});
}
function loadOnPaeuser(n,o){
n = jQuery.trim(n);
o = jQuery.trim(o);
if(n!=""){//&& n!=o
var nametemp = 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 提供数据代码:
public List findSomeDataByName(String name){
StringBuffer sql = new StringBuffer();
sql.append("select distinct NAME,ID from PERSONAL_AND_EXECUTIVE ");
sql.append("where ");
sql.append(" name like '%" + name + "%'");
final List list = new ArrayList();
getJdbcTemplate().query(sql.toString(), new Object[] {},
new RowCallbackHandler() {
public void processRow(ResultSet res) throws SQLException {
PersonalAndExecutive personalAndExecutive = new PersonalAndExecutive();
personalAndExecutive.setId(Integer.valueOf(res.getString("id")));
personalAndExecutive.setName(res.getString("NAME"));
list.add(personalAndExecutive);
}
});
return list;
}