easyuicombobobox 동적 귀속 데이터
4552 단어 easy-ui
class="easyui-combobox" id="first_catalogue" style="width:30%;" value="-- --" >
2.js
$(function(){
// $("#first_catalogue").parent(".l").show();
$('#first_catalogue').combobox({
url:'getDic/getFirstCategory.do?userCategory=${pd.userCategory}',
valueField:'id',
textField:'text',
required: true,
editable:false,
/* onLoadSuccess: function () { // ,
var val = $(this).combobox("getData");
//
$(this).combobox("select",val[0].text);
} , */
onChange: function (){
//getValue,getText value ,text
var val = $('#first_catalogue').combobox("getText");
alert(val);
}
});
//
/* var data,json;
data = [];
data.push({ "text": " ", "id":"xmjl" },{ "text": " ", "id":"xmjl" });
$("#first_catalogue").combobox("loadData", data); */
})
3. Colltroller의 작법
//
@RequestMapping(value="/getFirstCategory",produces="application/json;charset=utf-8")
@ResponseBody
//@ControllerInterceptor(Description=" ",Type=enumCtrlType.select)
public JSONArray getFirstCategory()throws Exception{
String returnCategory="";
JSONArray JsonArray = new JSONArray();
PageData pd = this.getPageData();
String userCategory = pd.getString("userCategory");
List firstCategory=ResoDictFacade.getFirstCategory(userCategory);
for(int i=0;i/*Map params = new HashMap();
params.put("text", Category);
params.put("id", "option_"+i);
JSONArray array = JSONArray.fromObject(params);
returnCategory+=array;*/
JSONObject Json = new JSONObject();
//JSONObject
Json.put("id", "option_"+i);
Json.put("text", Category);
// JSONObject Json
JsonArray.add(Json);
}
return JsonArray;
}