easyuiのcombobox 2次連動
2329 ワード
jspページ
バックグラウンドJavaコードロジック
:
:
jsコード$(function() {
var _adminLevel = $('#adminLevel').combobox({
data :jsongl_xzjb,
method :'get',
editable: false,
valueField:'CODE',
textField:'CODETEXT',
onSelect: function (record) {
_zhbid.combobox({
disabled: false,
url: "BaseRoadSeg.ered?reqCode=selectRoadName&adminLevel=" + record.CODE,
valueField: 'roadNo',
textField: 'roadName'
}).combobox('clear');
}
});
var _zhbid = $('#roadNo').combobox({
disabled: true,
valueField: 'roadNo',
textField: 'roadName'
});
});
バックグラウンドJavaコードロジック
public ActionForward selectRoadName(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String adminLevel="";
if(G4Utils.isNotEmpty(request.getParameter("adminLevel"))){
//
adminLevel = new String(request.getParameter("adminLevel").getBytes("GBK"), "utf-8");
}
List listLaws = g4Reader.queryForList("BaseRoad.getBaseRoadDtoByadminLevel", adminLevel);
String jsonString = JsonHelper.encodeObject2Json(listLaws);
write(jsonString, response);
return mapping.findForward(null);
}
sql文
が返すデータフォーマット[{
"roadNo":"1111",
"roadName":"111"},
{"roadNo":"453454",
"roadName":"5345"},
{"roadNo":"55345",
"roadName":"4534"
}]