<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ page import="java.io.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/jsp/common/include/localemessage.jsp" %>
<%
	response.setHeader("Pragma", "No-cache");
	response.setHeader("Cache-Control", "no-cache");
	response.setHeader("Expires", "0");

%>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<jsp:include page="/jsp/common/include/css.jsp"/>
<jsp:include page="/jsp/common/include/script.jsp"/>
<script language="javascript" >
var codeName = window.dialogArguments["codeName"];
var codeGroup = window.dialogArguments["codeGroup"];
// var codeGroupName = window.dialogArguments["codeGroupName"];

var url = '<c:url value="/common/acl/monitoringCode/monitoringCodeMan.json" />';


$(document).ready(function() {	
	
	//$('input[name=searchCodeName]').val(codeName);
// 	$('.title').text(codeGroupName+" 조회");
	$('#grid').jqGrid({
		datatype : "json",
		mtype : 'POST',
		url : url,
		postData : {cmd : "LIST_POP", searchCodeName : $('input[name=searchCodeName]').val() , codeGroup : codeGroup },
		colNames : [ 
		            '<%= localeMessage.getString("moniCdManSrchPop.cd")%>',
// 		            codeGroupName
		            '<%= localeMessage.getString("moniCdManSrchPop.extInsNm")%>'
		              ],
		colModel : [ 
					{ name : 'CODE'					, align:'center', width: "25%"},
					{ name : 'CODENAME'				, align:'left'  , width: "75%"}
 					],
		jsonReader : {
			repeatitems : false
		},
		pager : $('#pager'),
		page : '${param.page}',
		rowNum : '${rmsDefaultRowNum}',
		autoheight : true,
		height : $("#container").height(),
		autowidth : true,
		viewrecords : true,
		rowList : eval('[${rmsDefaultRowList}]'),
		loadComplete:function (d){
			var colModel = $(this).getGridParam("colModel");
			for(var i = 0 ; i< colModel.length; i++){
				$(this).setColProp(colModel[i].name, {sortable : false});
			}
		},
        loadError: function (jqXHR, textStatus, errorThrown) {
        	
        	var location ='<%=request.getContextPath()%>/';
        	comloadError(jqXHR, textStatus, errorThrown ,location);
        	
    	},		
		ondblClickRow: function(rowId) {
			var rowData = $(this).getRowData(rowId);
			var code = rowData['CODE'];
			var codeName = rowData['CODENAME'];
			var retData=new Object() ;
			retData['code'] = code;
			retData['codeName'] = codeName;
			
			window.returnValue = retData;
			$("#btn_close").trigger("click");
        }	
		
	
	});
	
	resizeJqGridWidth('grid','title','470');

	$("#btn_search").click(function(){
	   
	   var _searchCodeName = $('input[name=searchCodeName]').val();


		$("#grid").setGridParam({ postData:{cmd:"LIST_POP",searchCodeName:_searchCodeName} ,page : "1" }).trigger("reloadGrid");
	});
	$("#btn_close").click(function(){
		window.close();
	});
	
	$("input[name^=search]").keydown(function(key){
		if (key.keyCode == 13){
			$("#btn_search").click();
		}
	});
	
	//buttonControl();
	
}); 
 
</script>
</head>
	<body>
		<div class="popup_box">
			<div class="search_wrap">
<%-- 				<img src="<c:url value="/img/btn_search.png"/>" alt="" id="btn_search" level="W" /> --%>
<%-- 				<img src="<c:url value="/img/btn_close.png"/>" alt="" id="btn_close" level="R" />	 --%>
				<button type="button" class="cssbtn" id="btn_search" level="W"><i class="material-icons">search</i> <%= localeMessage.getString("button.search") %></button>
				<button type="button" class="cssbtn" id="btn_close" level="R"><i class="material-icons">cancel</i> <%= localeMessage.getString("button.close") %></button>
			</div>
			<div class="title"><%= localeMessage.getString("moniCdManSrchPop.extInsNmSrc")%></div>
			<table class="search_condition" cellspacing=0;>
				<tbody>
					<tr>
						<th style="width:200px;"><%= localeMessage.getString("moniCdManSrchPop.extInsNm")%></th>
						<td><input type="text" name="searchCodeName" value=""></td>							
					</tr>
				</tbody>
			</table>
			<table id="grid" ></table>
			<div id="pager"></div>
			
		</div><!-- end.popup_box -->
	</body>
</html>