$("#communityId").change( function(){ var id = $(this).children('option:selected').val(); //當前選擇項的值 var url = "sUserorderController.do?getCampaign&comid=" + encodeURIComponent(encodeURIComponent(id)); $.ajax({ type : 'POST', url : url, success : function(data) { var d = $.parseJSON(data); if (d.success) { window.top.$.messager.progress('close'); $('#campaignId').html(d.msg); } } }); });
首先是
為小區這個下拉選項添加 onchange事件,當點選communityId元素下拉事件時,通過ajax查詢第二級select選擇框內的值。(這里的actoin是sUserorderController.do?getCampaign )。
jeecg 默認的標簽 ,query="true" model="single" 增加的檢索項是不帶ID的,不過原理一樣。 可以根據name獲取dom元素。亦或修改jeecg源代碼,為檢索項添加id的概念。
具體代碼在
org\jeecgframework\tag\core\easyui\DataGridTag.java
只需要為select 增加 id 即可。
if("single".equals(col.getQueryMode())){ if(!StringUtil.isEmpty(col.getReplace())){ sb.append("<select id=\""+col.getField().replaceAll("_","\\.")+"\" name=\""+col.getField().replaceAll("_","\\.")+"\" WIDTH=\"100\" style=\"width: 104px\"> "); sb.append(StringUtil.replaceAll("<option value =\"\" >{0}</option>", "{0}", MutiLangUtil.getMutiLangInstance().getLang("common.please.select"))); String[] test = col.getReplace().split(","); String text = ""; String value = ""; for (String string : test) { String lang_key = string.split("_")[0]; text = MutiLangUtil.getMutiLangInstance().getLang(lang_key); value =string.split("_")[1]; sb.append("<option value =\""+value+"\">"+text+"</option>"); } sb.append("</select>"); }else if(!StringUtil.isEmpty(col.getDictionary())){ if(col.getDictionary().contains(",")){ String[] dic = col.getDictionary().split(","); String sql = "select " + dic[1] + " as field," + dic[2] + " as text from " + dic[0]; systemService = ApplicationContextUtil.getContext().getBean( SystemService.class); List<Map<String, Object>> list = systemService.findForJdbc(sql); sb.append("<select id=\""+col.getField().replaceAll("_","\\.")+"\" name=\""+col.getField().replaceAll("_","\\.")+"\" WIDTH=\"100\" style=\"width: 104px\"> "); sb.append(StringUtil.replaceAll("<option value =\"\" >{0}</option>", "{0}", MutiLangUtil.getMutiLangInstance().getLang("common.please.select"))); for (Map<String, Object> map : list){