<table style="margin-top: 50px;" id="dgs" title="大箱碼關聯信息列表" class="easyui-datagrid" toolbar="#toolbar" rownumbers="true" singleSelect="true" fitColumns="true"> <thead> <tr> <th data-options="field:'storecode',width:100,align:'center'">大箱碼</th> <th data-options="field:'casecode',width:300,align:'center'">關聯的箱碼(不一樣箱碼用分號分開,相同箱碼用逗號分開)</th> <th data-options="field:'count',width:100,align:'center'">關聯數量</th> </tr> </thead> </table> <div id="pp" class="easyui-pagination" style="border:1px solid #ccc;" data-options=" total: 0, pageSize:15, pageList: [15,30,50,100], onSelectPage: function(pageNumber, pageSize){ // 頁面切換動做 getDataByPageRows(pageNumber,pageSize); }"> </div>
function getDataByPageRows(pageNum, rowsLimit){ $("#pp").show(); pageNum = pageNum || 1; // 設置默認的頁號 rowsLimit = rowsLimit || 2;// 設置默認的每頁記錄數 $.ajax({ type: "POST", dataType: 'json', // 注意格式是html,不是json url:"<%=basePath%>outdata/querydetaillist", data: { startdate: $("#startdate").datetimebox('getValue'), enddate: $("#enddate").datetimebox('getValue'), storecode: $("#storecode").val(), page: pageNum, rows: rowsLimit }, success: function(data){ // 請求成功,將返回的數據(一頁的記錄數)綁定到 datagrid控件 var count = data.total; // 總記錄個數 var datarow = data.rows; //獲取條數; $('#dgs').datagrid('loadData',datarow); $('#pp').pagination({ total: count, // 因爲顯示 」共XXX條記錄」 等信息用 pageNumber: pageNum // }); } });//ajax }
@RequestMapping(value="/querydetaillist") @ResponseBody public String querydetaillist(Model model,HttpServletResponse response,HttpServletRequest request, @RequestParam(value = "page", required = false, defaultValue = "") String page, @RequestParam(value = "storecode", required = false, defaultValue = "") String storecode, @RequestParam(value = "startdate", required = false, defaultValue = "") String startdate, @RequestParam(value = "enddate", required = false, defaultValue = "") String enddate, @RequestParam(value = "rows", required = false, defaultValue = "") String rows){ int endindex=Integer.valueOf(page)*Integer.valueOf(rows); int startindex=(Integer.valueOf(page)-1)*Integer.valueOf(rows); Map<String,Object> params = new HashMap<String, Object>(); if(!storecode.equals("")){ storecode = storecode.replaceFirst("^0*", ""); } if(!startdate.equals("")){ startdate = startdate.replaceAll(" ", ""); } if(!enddate.equals("")){ enddate = enddate.replaceAll(" ", ""); } params.put("endIndex", endindex); params.put("storecode", storecode); params.put("startIndex", startindex); params.put("startdate", startdate); params.put("enddate", enddate); List<Store> datalist=outdataDao.querydetaillist(params); String total=outdataDao.querydetaillistcount(params); JSONObject obj=new JSONObject(); obj.put("total", total); obj.put("rows", datalist); return obj.toJSONString(); }
<select id="querydetaillist" resultType="Store" parameterType="Map"> select * from ( select tt1.*, ROWNUM as rowno from ( select storecode,listagg(casecode,';') within group (order by casecode) as casecode,count(casecode) as "count" from ( select s.storecode,c.caseid,listagg(c.casecode,',') within group (order by c.casecode,c.caseid) as casecode, count(distinct caseid) from ys_store s left join ys_case c on s.id=c.storeid where 1=1 and casecode is not null <if test="startdate != null and startdate != ''"> and to_char(s.gldate,'yyyy-MM-dd')>='${startdate}'</if> <if test="enddate != null and enddate != ''"> and to_char(s.gldate,'yyyy-MM-dd')<='${enddate}'</if> <if test="storecode != null and storecode != ''"> and s.storecode=${storecode}</if> group by s.storecode,c.caseid ) group by storecode ) tt1 where ROWNUM <= '${endIndex}') tt2 where tt2.rowno > '${startIndex}' </select> <select id="querydetaillistcount" resultType="String" parameterType="Map"> select count(*) from( select storecode,listagg(casecode,';') within group (order by casecode) as casecode,count(casecode) as "count" from ( select s.storecode,c.caseid,listagg(c.casecode,',') within group (order by c.casecode,c.caseid) as casecode, count(distinct caseid) from ys_store s left join ys_case c on s.id=c.storeid where 1=1 and casecode is not null <if test="startdate != null and startdate != ''"> and to_char(s.gldate,'yyyy-MM-dd')>='${startdate}'</if> <if test="enddate != null and enddate != ''"> and to_char(s.gldate,'yyyy-MM-dd')<='${enddate}'</if> <if test="storecode != null and storecode != ''"> and s.storecode=${storecode}</if> group by s.storecode,c.caseid ) group by storecode ) </select>
easyui 中文網:http://www.jeasyui.net/plugin...
oracle多行合併成一行: listagg within group:http://blog.csdn.net/baojiang...html