日期:2014-05-17  浏览次数:20862 次

jqGrid 分页总页数不显示
java:
   HttpServletRequest request = ServletActionContext.getRequest();  
    HttpServletResponse response = ServletActionContext.getResponse();  
    String page = request.getParameter("page"); //取得当前页数  
    
    
    String rows = request.getParameter("rows"); //取得每页显示行数  
    
    System.out.println("page+rows-----"+page+"   "+rows);
    
    int totalRecord = 80; //总记录数(应根据数据库取得,在此只是模拟) 
    int totalPage = 8;
//     int totalPage = totalRecord%Integer.parseInt(rows) == 0 ?   
//             totalRecord/Integer.parseInt(rows) : totalRecord/Integer.parseInt(rows)+1; //计算总页数  
    try {  
    int index = (Integer.parseInt(page)-1)*Integer.parseInt(rows); //开始记录数  
    
    System.out.println("index:"+index);
    
    int pageSize = Integer.parseInt(rows);  
              //以下模拟构造JSON数据对象  
    String json = "{total: "+totalPage+", page: "+page+", records: "+totalRecord+", rows: [";  
    for (int i = index; i < pageSize + index && i<totalRecord; i++) {  
        json += "{cell:['ID "+i+"','NAME "+i+"','PHONE "+i+"']}";  
        if (i != pageSize + index - 1 && i != totalRecord - 1) {  
            json += ",";  
        }  
    }  
    json += "]}";  
//     System.out.println(json);  
    response.getWriter().write(json); //将JSON数据返回页面  
    } catch (Exception ex) {  
    }