본문 바로가기

개발하자/jgGrid

editurl사용하기

aa.jsp

=======================

<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>

 <link rel="stylesheet" type="text/css" href="scripts/css/jquery-ui-

1.10.3.custom.css" />
 <link rel="stylesheet" href="scripts/css/ui.jqgrid.css" />
 <link rel="stylesheet" type="text/css" href="scripts/css/ui.multiselect.css" />
 <script src="http://code.jquery.com/jquery-1.7.js">
</script>
 <script src="scripts/js/i18n/grid.locale-en.js">
</script>
 <script src="scripts/js/jquery.jqGrid.min.js">
</script>
 <script src="http://code.jquery.com/jquery-migrate-1.2.1.js">
</script>
 <script type="text/javascript">
 $(document).ready(function(){ 
  $('#grid').jqGrid({
   url:'bb.jsp',
   datatype:'json',
   jsonReader:{page:'page',root:'list',total:'total'},
   colNames:['id','pw','ADDR','TEL'],
   colModel:[
    {name:'id',width:50, editable:false},
    {name:'pw',width:50, editable:true},
    {name:'addr',width:50, editable:true},
    {name:'tel',width:50, editable:true}
   ],
   width:500,
   viewrecords:true,
   rowNum:3,
   rowList:[3,6,9],
   caption:'회원리스트',
   pager:'#pager',
 editurl:"cc.jsp"

  });
  $("#grid").navGrid("#pager",  

{add:true,del:true,edit:true,search:true,refresh:true});
 });
 
 </script>
 </head>
 <body>
  <table id="grid"></table>
  <div id="pager"></div>
 </body>
</html>

 

bb.jsp

==================

<%@page import="kr.co.seoulit.member.to.MemberBean"%>
<%@page import="kr.co.seoulit.common.to.ListForm"%>
<%@page import="kr.co.seoulit.member.dao.MemberDAOImpl"%>
<%@page import="java.lang.reflect.Member"%>
<%@page import="kr.co.seoulit.member.dao.MemberDAO"%>
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<%@ page import="java.util.*" %>
<%@ page import="net.sf.json.*"%> 
<%
 int pagenum=Integer.parseInt(request.getParameter("page"));
 int rowsize=Integer.parseInt(request.getParameter("rows"));
 MemberDAOImpl dao=(MemberDAOImpl)MemberDAOImpl.getInstance();
 int dbcount=dao.selectRowCount();
 ListForm listForm=new ListForm();
 listForm.setRowsize(rowsize);
 listForm.setPagenum(pagenum);
 listForm.setDbcount(dbcount);
 int sr=listForm.getStartrow();
 int er=listForm.getEndrow();
 
 List<MemberBean> list=dao.selectMemberList(sr,er);
 HashMap<String,Object> map=new HashMap<String,Object>();
 int pagecount=listForm.getPagecount();
 map.put("page",pagenum);
 map.put("total",pagecount);
 map.put("list",list);
 JSONObject jsonObject=JSONObject.fromObject(map);
 
 
/*  Enumeration<String> arr=request.getParameterNames();

 while(arr.hasMoreElements()){
  String n=arr.nextElement();
  String v=request.getParameter(n);
 
  System.out.println("이름:"+n);
  System.out.println("값:"+v);
 } */
 out.println(jsonObject);


%>

cc.jsp

======================

<%@ page language="java" contentType="text/html; charset=EUC-KR"
 pageEncoding="EUC-KR"%>
<%@ page import="java.util.*" %>
<%

Enumeration<String> e=request.getParameterNames();
while(e.hasMoreElements()){
 String name=e.nextElement();
 String value=request.getParameter(name);
 System.out.println(name+","+value);
}

%>