본문 바로가기

개발하자/jgGrid

선택누르면 jqgrid에서 id값 alert에 띄우기

<%@ 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});

   $("#aTag").click(function(){
    var id=$('#grid').jqGrid("getGridParam","selrow");
    alert(id); });

 });
 
 </script>
 </head>
 <body>
  <table id="grid"></table>
  <div id="pager"></div>
  <a href="#" id="aTag">선택</a>
 </body>
</html>

 

 

 

 

비번띄우려면

 $("#aTag").click(function(){

   var id=$('#grid').jqGrid("getGridParam","selrow");

   if(id){
   var member= jQuery("#grid").jqGrid('getRowData',id);
   alert(member.pw);
   }else{
   alert("선택해라");
   }

   });

 });

'개발하자 > jgGrid' 카테고리의 다른 글

jqgrid 참고사이트  (0) 2015.03.18
jqGrid 이용하여 db테이블 불러와서 선택정보를 ajax로 json이용하여 나타내기  (0) 2015.03.17
editurl사용하기  (0) 2015.03.17
페이지카운트  (0) 2015.03.17
rowList:[3,6,9]  (0) 2015.03.17