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);

}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值