data 행을 JSON 형태로 설정하고 반환합니다.


요약

특정 data 행을 JSON 형태로 설정하고 반환합니다.

입력값

Number : Row Index

String : Json Data



예) datagrid1.setRowData(3, Json Data );
     datagrid1.getRowData(3);

상세설명

특정 행을 새로운 JSON DATA를 넣어서 그 행만 DATA를 변경시키고 그 변경된 값을 반환 할 수 있습니다.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page language="java"   contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html xmlns="http://www.w3.org/1999/xhtml" lang="ko" xml:lang="ko">
<head>
	<meta content="IE=9" http-equiv="X-UA-Compatible">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>SoftBowl SBGrid Example</title>
	<script type="text/javascript" src="../../kr/co/softbowl/js/Library/json-minified.js"></script>
	<script type="text/javascript" src="../../js/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" src="../../kr/co/softbowl/js/Library/json2.js"></script>
		
	<script type="text/javascript" src="../../kr/co/softbowl/SBGrid.js"></script>
	
	<script type="text/javascript" src="../../js/DATA_JSON_116_people.js"></script>
		
	<script type="text/javascript">			
		SBGrid.DEF.DOMAIN = "../../";
	<script>
	
	<script type="text/javascript">
        var datagrid1;
		
		$(document).ready(function(){
			__createElements();
		});
		
		
		function __createElements (){
	
			var obJson = 	{
								"strParentId" : "sbGridArea",
								"strId": "datagrid1",
								"strCaption": "FirstName^LastName^Company^Address^City^County^State^ZIP_Code^Phone^Fax^E-mail^HomePage Address",
								"strColWidth": "100, 100, 250, 250, 180, 150, 70, 100, 110, 110, 250, 300",
								"strJsonRef": "grid_data",
								"strDataHeight":"29",
								"strStyle": "width:100%; height:480px; ",
								"strBackColorAlternate" : "#f7f7f7",
								"strExplorerbar": "sortshow"	
					};
	
			datagrid1 = createSBDataGrid(obJson);
	
			var objJsonColumn = [
									{ "id": "col1", "type": "input", "ref": "FirstName" },
									{ "id": "col2", "type": "input", "ref": "LastName" },
									{ "id": "col3", "type": "input", "ref": "Company" },
									{ "id": "col4", "type": "input", "ref": "Address" },
									{ "id": "col5", "type": "input", "ref": "City" },
									{ "id": "col6", "type": "input", "ref": "County" },
									{ "id": "col7", "type": "input", "ref": "State", "style" : "text-align:center" },				
									{ "id": "col8", "type": "output", "ref": "ZIP", "style" : "text-align:center" },
									{ "id": "col9", "type": "output", "ref": "Phone", "style" : "text-align:center" },
									{ "id": "col10", "type": "output", "ref": "Fax", "style" : "text-align:center" },
									{ "id": "col11", "type": "output", "ref": "Email" },
									{ "id": "col12", "type": "output", "ref": "Web" }
					   ];
			datagrid1.createColumns(objJsonColumn);

		};

		function getRowData(){
			var objRowData = datagrid1.getRowData(2);
			alert("index가 2인 행의 Data는\n'" + JSON.stringify(objRowData) + "'\n입니다.");
		};

		function setRowData(){
				var objRowData = {
                   "FirstName": "Julia",
				   "LastName": "Cokins",
                   "Company": "Contact",
				   "Address": "5600 N Inperial Ave",
                   "City": "Los Angeles",
                   "County": "Kings",
                   "State": "FL",
				   "ZIP" : "99999",
				   "Phone" : "999-999-9999",
				   "Fax" : "999-999-9999",
				   "Email" : "julia@contact.com",
				   "Web" : "http://www.contact.com"
				   
               }
			   alert("index가 2인 행의 Data를 \n'" + JSON.stringify(objRowData) + "'\n로 설정합니다.");
			   datagrid1.setRowData(2, objRowData);
	    };

	</script>
</head>
<body>

    <div id="button_group">
    	<input type="button" class="sbgrid_demo_button2" style="width:33%; height:30px; background-color:#F2CB61;" id="button1" value="2행의 data를 JSON 형태로 적용" onclick="setRowData();"/>
    	<input type="button" class="sbgrid_demo_button2" style="width:33%; height:30px; background-color:#FFC19E;" id="button2" value="2행의 data를 JSON 형태로 반환" onclick="getRowData();"/>
    </div>
    <div id="sbGridArea"></div>
			
</body>
</html>