欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

struts2 easyui combobox

程序员文章站 2022-03-13 23:26:14
...

今天花了半天才搞定。

网上找了不少例子。最后搞定了。

 效果图
struts2 easyui combobox
            
    
    博客分类: 技术简介 struts2easyuicombobox下拉框 
 

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

}

 

  • struts2 easyui combobox
            
    
    博客分类: 技术简介 struts2easyuicombobox下拉框 
  • 大小: 11.9 KB