struts2 easyui combobox
今天花了半天才搞定。
网上找了不少例子。最后搞定了。
效果图
<input id="wifis_barId_index" class="easyui-combobox" />
/**下拉框初始化*/
from_initUserCombox();
function from_initUserCombox() {
$.ajax({
url:"barapp/Bars/getComboBox.do",
cache: false,
dataType:"json",
success: function(result){
//alert("ok"+result.list[0].id);
var feiqumingxiarr = new Array();
feiqumingxiarr =result.list;
$("#wifis_barId_index").combobox({
data : feiqumingxiarr,
valueField : 'id',
textField : 'name'
});
},
error : function(){
alert("error");
}
});
//$("#wifis_barId_index").combobox({
//url:"barapp/Bars/getComboBox.do",
//valueField:'id',
//textField:''
//});
}
后台返回JSON串
{"list":[{"annexList":[],"city":"长沙","explains":"诞集团。","id":1,"idList":[],"logPic":"http://117.40.178.58:7070/bar/upload/bar/1.jpg","name":"苏荷酒吧","password":"888888","tel":"13786141175"},{"annexList":[],"city":"长沙","explains":"分为演艺吧。","id":2,"idList":[],"logPic":"http://117.40.178.58:7070/bar/upload/bar/2.jpg","name":"魅力四射","password":"888888","tel":"0731-85171988"}],"success":false}
/**
* <p>标题:下拉框所用 列表
* @throws IOException
*/
public void getComboBox() throws IOException {
Map<String, Object> result = new HashMap<String, Object>();
List list = new ArrayList();
try {
String str = "";
Bars barsobj = new Bars();
list = barsManager.findAll();
result.put("success", false);
result.put("list", list);
} catch (Exception e) {
e.printStackTrace();
}
outJson(result);
}
上一篇: python如何验证中心极限定理
下一篇: 二分查找、顺序查找