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; }