easyui初始化和下拉框
阿新 • • 發佈:2019-02-15
easyUi初始化
$("#tt2").datagrid({ url: _ctx + '/energyefficiency/queryAllEnergyEfficiency.do', pagination: true, rownumbers: true, fitColumns: true, pageSize: DEFAULT_PAGE_SIZE, pageList: DEFAULT_PAGE_LIST, pageNumber: 1, singleSelect: false, fit: true, loadMsg: "正在載入...", rowStyler:function(index,row){ if ((index+1)%3==0){ return 'background-color:#F4F4F4;'; }else{ return 'background-color:#fff;'; } }, queryParams: { indexName: $.trim($("#index_name").textbox("getValue")), indexType: $.trim($("#index_type").textbox("getValue")), deptPath:deptPath }, onLoadError: function () { jError("查詢失敗", { VerticalPosition: 'center', HorizontalPosition: 'center', ShowOverlay: false }); } });
easyUI下拉框
前臺:
$("#indexType").combobox({
required: true,
url:_ctx +'/energyefficiency/queryIndexTypeSelect.do', //後臺獲取下拉框資料的url
method:'post',
panelHeight:150,//設定為固定高度,combobox出現豎直滾動條
valueField:'code',
textField:'name',
multiple:false,
editable: false
});
這裡是input標籤而不是select
<input class="easyui-combobox" id="indexType" name="indexType" style="width: 100%" data-options="required:true">
後臺方法如下:
public String queryIndexTypeSelect(String type){ String data ; JSONObject json = new JSONObject(); JSONArray array = new JSONArray(); try { SysDictionary dictionary = new SysDictionary(); //能效指標型別 dictionary.setParentId(type); List<Map> energyEfficiencyLst = sysDictionaryServiceImpl.queryDictionaryByParentId(dictionary); if(!energyEfficiencyLst.isEmpty()){ for(Map<String,Object> lb : energyEfficiencyLst){ json.put("code", lb.get("code")); json.put("name", lb.get("name")); array.add(json); } } data = array.toString(); } catch (Exception e) { logger.error("{}", e); data="{}"; } return data; }