기본에 있던 소스를 변경하였다(페이징을 하기 위해서 변경하여만햇다 )
vo자체를 넘기는거는 그냥 rows 즉 데이터만 넘기는 것이라서 map에 담았다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | //사원정보 jqgrid, json으로 변형한 데이터 @RequestMapping(value = "/gridView.do", method = RequestMethod.POST) @ResponseBody //json으로 변환 ====> 원래는 LIST<EmployeeVO> public HashMap<String, Object> gridView(EmployeeVO vo, Model model, @RequestParam(value = "page", required = false, defaultValue = "1") int page, @RequestParam(value = "rows", required = false, defaultValue = "20") int rows, @RequestParam(value = "total", required = false, defaultValue = "20") int total, @RequestParam(value = "records", required = false, defaultValue = "20") int records, @RequestParam(value = "sord", required=false, defaultValue="sort") String sord) { page : 현재 호출되는 페이지 rows : 데이터 total : 총 페이지 수 records : 총 데이터 수 sord : 정렬 System.out.println("page :"+page+", rows :"+rows+", total :"+total+", sord :"+sord); //page :1, rows :5, total :20 ,sord :desc System.out.println("/gridView.do"); List<EmployeeVO> empVo = null; empVo = employeeServiceimp.AllEmployeeList(); System.out.println("jqgrid조회 : "+empVo); HashMap<String, Object> resMap = new HashMap<String, Object>(); total = employeeServiceimp.totalCount(rows); records = employeeServiceimp.totalRecords(); <select id="totalCount" resultType="int" parameterType="int">
select
(count(*)/#{rows}) from employee
</select>
<select id="totalRecords" resultType="int" parameterType="int">
select
count(*) from employee
</select> resMap.put("page", page); resMap.put("total", total); // 총페이지 resMap.put("records", records); // 총레코드 ====> 페이징을 하기 위해 resMap.put("rows", empVo); return resMap; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | // 사용자정보 그리드 $(document).ready(function() { // 사용자 조회 jqgrid //$.jgrid.gridUnload("list2"); $("#list2").jqGrid({ url : '/library/gridView.do', // 데이터가있는 url 매핑 datatype : 'json', jsonReader : { // controller에서 리턴한 값 root : "empVo" ==> rows : "empVo", // root로 하니 데이터를 못 찾아서 rows로 바꾸니 매핑이됨 page : 'page', total : 'total', records : 'max' ==> records : 'records', repeatitems:false }, mtype : 'POST', // 데이터 전송방식 colNames : [ '사원ID', '이름', '사원번호', '부서', '직급', '사원상태', '입사일', '비고' ], // 컬럼명 colModel : [ { // JSON 데이터의 키값과 colModel의 name값이 일치해야만 매핑이 된다 name : 'ename', index : 'ENAME', align : 'center', width : 60, editable : true, edittype : "text" }, { name : 'name', index : 'NAME', align : 'center', width : 60, editable : true, edittype : "text" }, { name : 'dcode', index : 'DCODEE', align : 'center', width : 60, editable : true, edittype : "text" }, { name : 'department', index : 'DAPARTMENT', align : 'center', width : 60, editable : true, edittype : "text" }, { name : 'position', index : 'POSITION', align : 'center', width : 60, editable : true, edittype : "text" }, { name : 'present', index : 'PRESENT', align : 'center', width : 60, editable : true, edittype : "text" }, { name : 'bireday', index : 'BIREDAY', align : 'center', width : 60, editable : true, edittype : "text", formatter : "date", formatoptions : { newformat : " Y/m/d" } }, { name : 'note', index : 'NOTE', align : 'center', width : 60, editable : true, edittype : "text" } ], rowNum : 5, rowList : [ 5, 10, 15, 30 ], // 페이지에서 보여줄 레코드 갯수 viewrecords : true, // //recordtext:"페이지 {0} - {1} of{2}", sortname : 'dcode', sortorder : "desc", caption : "책조회", width : 850, height : '450px', showpage:true, // 페이징 true multiselect : true, pager : $('#pager'), emptyrecords : "데이터가 없습니다.", // 레코드가 없을때 보여줄 문구 loadonce:false ==> loadonce:true // false였을때는 페이지를 넘겨도 첫 페이지에 데이터 그대로 보임 true로 바꾸니 페이지를 넘기면 데이터도 바뀜 ㅜㅜ 쌩고생 http://devesim.tistory.com/8 이거보고 고침... }); but true로 고치니맨처음 한번밖에 로딩을 안해서 수정,정력이 안됨... 리로드 자체가 안됨 }); // document | cs |
'개발 > 개인' 카테고리의 다른 글
사용자 정보 상세조회2 //replace 사용하기 (0) | 2016.11.09 |
---|---|
사내도서대여시스템 - 사용자정보 조회2 // 정규식 (0) | 2016.11.08 |
사용자 수정,상세보기 - 그리드 체크박스 해제 (0) | 2016.11.02 |
사용자 정보 수정, 상세보기 - modal창 제어(선택된데이터가 있을때 없을때) (0) | 2016.11.02 |
사용자 정보 입력하기 - 유효성검사 추가,입력폼 reset (0) | 2016.11.02 |
댓글