87,901
社区成员
发帖
与我相关
我的任务
分享
<input id="dept" class="easyui-combobox" name="department_name" style="width: 220px"
data-options="editable:false,panelHeight:'auto'">
$(document).ready(function() {
$.ajax({
url : '${pageContext.request.contextPath}/dept/getcombobox',
type : 'post',
valueField : 'id',
textField : 'name',
success : function(data) {
var themecombo = [];
for ( var i = 0; i < data.length; i++) {
themecombo.push({
"id" : data[i].id,
"text" : data[i].name
});
}
$("#dept").combobox("loadData", themecombo);
if (data) {
$('#dept').combobox('setValue', data[0].name);
}
}
});
});
@RequestMapping("/getcombobox")
@ResponseBody
public JSONArray getDept(HttpServletRequest request) {
....
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
....
JSONArray jsonArray = JSONArray.fromObject(list);
return jsonArray;
}