页面输入框展现列表以及选中获取

来源:互联网 发布:figma软件 编辑:程序博客网 时间:2024/06/05 06:33
/**
* 获取展现在输入框的列表,数据库中读取组合

* @return
*/
@RequestMapping("/querysupplierManage")
public @ResponseBody
String querysupplierManage() {
List<Map<String, Object>> list = pms.getSupplierList();
JSONObject json=new JSONObject();
json.put("message", "");
JSONArray array=new JSONArray();
Iterator<Map<String, Object>> it1 = list.iterator();
//Pinyin4j pinyin4j=new Pinyin4j();
JSONObject jsonObject1=new JSONObject();
         //jsonObject1.put("userName","");
         //jsonObject1.put("shortAccount","");
         array.add(jsonObject1);
while(it1.hasNext()){
            Map<String, Object> map=it1.next();
            //String numbers=String.valueOf("numbers").trim();
            //numbers=map.get("numbers").toString().trim();
            String id= map.get("id").toString();
            String no=(String) map.get("no");
            JSONObject jsonObject=new JSONObject();

            //jsonObject.put("userName", pinyin4j.getPingYin(name));

注意以下两句的顺序,关于哪个输入框展现哪个字段

            jsonObject.put("userName",no);

            jsonObject.put("shortAccount",id);


            //jsonObject.put("shortAccount",numbers);
            array.add(jsonObject);
        }
json.put("value", array);
json.put("code", "200");
json.put("redirect", "");
//System.out.println(json.toString());
return json.toString();

}




 var testBsSuggest=$("#no").bsSuggest({url:"<%=root%>/unphonethe/querysupplierManage.do",showBtn:true,indexKey:1}).on("onDataRequestSuccess",function(e,result){console.log("onDataRequestSuccess: ",result)}).on("onSetSelectValue",function(e,keyword){console.log("onSetSelectValue: ",keyword)
    $('#id1').val(keyword.id);
    }).on("onUnsetSelectValue",function(e){console.log("onUnsetSelectValue")});

1 0
原创粉丝点击