EasyUI Datagrid

1.頁面展現效果:html

![圖片上傳中...]ajax

頁面:

<table style="margin-top: 50px;" id="dgs" title="大箱碼關聯信息列表" class="easyui-datagrid"sql

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>

## js代碼: ##
 /*列表  */

 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         
       }  
       
       
       ## controller層: ##
       @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();
}

sql:

<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')&lt;='${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 &lt;= '${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')&lt;='${enddate}'</if>
                 <if test="storecode != null   and storecode != ''"> and s.storecode=${storecode}</if>
                  group by s.storecode,c.caseid
                )
                group by storecode
        )
    </select>
相關文章
相關標籤/搜索