2017년 11월 9일 목요일

jqGrid 페이징 자바 셋업




/**
 * SJJO 제작. 2014.09.17
 * jqGrid 페이징 쿼리날릴때 셋업
 * 서비스(뷰) -> DB 쿼리 
 * 쿼리에 필요한 변수 startPage(시작 로우), endPage(끝 로우), sidx(정렬 컬럼명), sord(오름차순 내림차순)
 * page : 현재 페이지
 * rows : 한페이지당 로우 갯수
 * @param map
 * @return
 */
public Map jqGridPagingMap(Map map) {
double rows = (Integer) map.get("rows");
int page= (Integer) map.get("page");
Object searchObj  = map.get("_search");
String sidx = (String)map.get("sidx");
String sord = (String) map.get("sord");
int endPage = page * (int)rows;
int startPage = endPage - (int)rows + 1;
HashMap resultMap = new HashMap();
resultMap.put("startPage", startPage);
resultMap.put("endPage", endPage);
resultMap.put("page", page);
resultMap.put("sidx", sidx);
resultMap.put("sord", sord);
resultMap.put("rows", rows);
return resultMap;
}
/**
 * SJJO 제작. 2014.09.17
 * jqGrid 페이징 처리 view에 보내는 세팅
 * 서비스 -> 뷰
 * page: 현재 페이지
 * total : 총 페이지
 * records : 로우 총 갯수
 * rows : 실제 데이터 리스트
 * @param map
 * @param list
 * @param count
 * @return
 */
public Map jqGridPagingResultMap(Map map, List list, double count) {
int page = (Integer) map.get("page");
double rows = (Double) map.get("rows");
int total = (int) Math.ceil(count/rows);
//system.out.println(list);
HashMap resultMap = new HashMap();
resultMap.put("page", page);
resultMap.put("total", total);
resultMap.put("records", count);
resultMap.put("rows", list);
return resultMap;



댓글 없음:

댓글 쓰기