easyui 日期范围前后台的设置以及实现
1.页面部分(引入相应的js)
<td class="w40 tl pl10">从日期:</td> <td> <input class="easyui-datebox stdfrm-b2" name="mDateBegin" id="mDateBegin" style="width: 158px;" data-options="validType:'date',height:23"></input> </td> <td class="w40 tl pl10">到日期:</td> <td> <input class="easyui-datebox stdfrm-b2" name="mDateEnd" id="mDateEnd" style="width: 158px;" data-options="validType:'date',height:23"></input> </td>
<span style="float:left;margin-left:80px;margin-top:12px;"><a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-fi-search'" style="width:80px" onclick="doQuery();">查询</a></span>
2.js
/** * 查询 */ function doQuery(){ $('#dg_menu').datagrid('reload',{ 'mDateBegin': $('#mDateBegin').datebox('getValue'), 'mDateEnd': $('#mDateEnd').datebox('getValue'), 'code': $('#mealtime').combobox('getValue') }); }
3.后台
public String queryMenu() throws Exception{ HttpServletRequest request = this.getRequest(); String mDateBegin = request.getParameter("mDateBegin"); String mDateEnd = request.getParameter("mDateEnd"); String type = request.getParameter("code"); if("请选择".equals(type)){ type = null; } if(conditions == null){ conditions = new ArrayList(); } if(mDateBegin != null && !mDateBegin.equals("")){ Condition c1 = new Condition(); c1.setPropertyKey("mDate"); c1.setPropertyExpression(">="); c1.setPropertyValue(mDateBegin); conditions.add(c1); } if(mDateEnd != null && !mDateEnd.equals("")){ Condition c2 = new Condition(); c2.setPropertyKey("mDate"); c2.setPropertyExpression("<="); c2.setPropertyValue(mDateEnd); conditions.add(c2); } if(type != null && !type.equals("")){ Condition c3 = new Condition(); c3.setPropertyKey("mealtime"); c3.setPropertyExpression("="); c3.setPropertyValue(type); conditions.add(c3); } Map map = (Map) this.menuService.queryMenu(conditions, pager, sorter); jsonConfig.registerJsonValueProcessor(Date.class,new JsonDateValueProcessor()); this.utf8ResponseWriter().write( JSONObject.fromObject(map, jsonConfig).toString()); return null; }
以上代码不是完整,
待续……