/*************************************************************************************************** * JqGrid 전역설정 - 공통 옵션 설정 **************************************************************************************************/ jQuery.extend( jQuery.jgrid.defaults, { rowNum: 15, //999999999999, //rowNum: 20, rowList: [], //rowList: [], datatype: "local", //datatype: "xml", -> json에서 local로 변경함. json으로 설정하면 데이터를 조회 하지 않으면 loadError(Code 200)가 발생함. autoencode: true, mtype: "POST", //mtype: "GET", jsonReader : { root: "records", id: "id" }, //jsonReader: {}, viewrecords: true, // 화면 하단에 총 몇개중에서 몇번째꺼를 보여주고 있는지 //viewrecords: false, loadonce: true, //sort등 이벤트 시 재조회 하지 않도록 //loadonce: false, cellsubmit: "clientArray", //row단위로 저장하지 않고 일괄 처리 //cellsubmit: "remote", autowidth: true, //autowidth: false, shrinkToFit: false, //shrinkToFit: true, gridview: true, //처리속도를 빠르게 해준다. treeGrid, subGrid, afterInsertRow(event) 은 사용 불가. //gridview: false, rownumbers : true, //rownumbers : false, rownumWidth : 35, //rownumbers 컬럼 폭, rownumWidth : 25 ajaxGridOptions :{cache: false}, //ajaxGridOptions :{}, //onSortCol, loadComplete, onInitGrid, loadError 이벤트는 공통 기능 적용을 위하여 여기서 설정하고, //각 페이지별로 추가 정의가 필요할 경우 jQuery.bind() 를 이용하여 정의한다. //================================================================================ //컬럼 sort시 발생하는 loadComplete 이벤트에서는 데이터셋 초기화를 하지 않도록 //"_isSorted" 속성을 만들고 여기에 true를 셋팅한다. onSortCol: function(index, iCol, sortorder) { this._isSorted = true; }, loadComplete : function(data) { var isSorted = false; try { isSorted = this._isSorted; } catch(e) { console.log("error!!!"); } //에러 무시 //조회 처리 완료(재조회 등) 후 에러가 없고 sorting으로 인해 발생한 경우가 아니라면 //내부 데이터셋 개체 초기화 처리 if (!data.error_message && !isSorted) { // console.log("ID:" + this.id + " Global loadComplete Event 에서 initGridDataSet 호출 됨."); $(this).jqGrid("initGridDataSet"); } this._isSorted = false; //postData도 조회전에 setGridParam 하여도 이전것이 남아있다. //예를들어 체크박스 CHK_IMPACT_SCOPE 로 선택값이 4개 였다가 //이번에 두개만 선택했다고 하면 CHK_IMPACT_SCOPE가 지금 선택한 2개로 대체되는 것이 아니라 //기존의 0~3 까지의 배열요소중 0, 1번만 변경되고 2,3번은 이전것이 남아 있는다. //따라서 이곳에서 초기화 하여준다. 조회 클릭시 새로 셋팅하므로 문제가 없어 보인다. $(this).jqGrid("setGridParam", {postData: null}); }, onInitGrid : function() { // console.log("ID:" + this.id + " Global onInitGrid Event 호출 됨."); //각 페이지별로 최초에 설정한 그리드 높이를 저장(resize에 의해 변경 되므로) 하기 위하여 //_orgHeight 라는 option을 임의로 만들어서 저장한다. $(this).jqGrid("setGridParam", {_orgHeight: $(this).jqGrid("getGridParam", "height")}); //이곳에서 grid obj 안에 _solutisGridDataSet 이라는 필드를 생성한다. $(this).jqGrid("initGridDataSet"); //필수입력 컬럼 헤더에 표시 $(this).jqGrid("markRequiredAtHeader"); //rownumbers: true 인 경우. "번호" 타이틀 셋팅 if ($("div#jqgh_" + this.id + "_rn").length > 0) { $("div#jqgh_" + this.id + "_rn").html('Number' + $("div#jqgh_" + this.id + "_rn").html()); } //edittype 이 checkbox 면서 formatter도 checkbox로 주었을 경우 //checkbox의 값을 변경 하여도 jqGrid 의 getChangedCells 의 메서드에서 해당행이 return 되지 않는다. //(단 checkbox 외의 cell 영역을 클릭하면 edit mode로 들어가므로 이때는 getChangedCells 함수에서 return 된다. // 즉 formatter 에 의해 밖으로 보여지는 checkbox를 바로 클릭시 문제 임.) //jqGrid의 bug로 보여지며, 이에 따라 jquery를 이용하여 그리드내의 checkbox에 onChange 이벤트리스너에 //해당 tr 과 td에 변경사항이 있음을 판단하는 class를 추가하여 준다. //document 에 on 메서드를 이용하여 이벤트를 정의하면 정의 후 생기는 selector의 element에도 이벤트가 등록된다. //2014.07.08 김철현 $(document).on("change", "#" + this.id + " td[role='gridcell'] input[type='checkbox']", function(){ $(this).parent("td").addClass("dirty-cell"); $(this).parent("td").parent("tr").addClass("edited"); }); }, loadError: common_callbackAjaxLoadError } ); $.jgrid.extend({ initGridDataSet: function() { this.each(function(){ if(!this.grid) {return;} //서버에서 I,D,U 형태로 구분하여 받을수 있도록 처리 //해주기 위한 solutis 자체제작 클래스 this._solutisGridDataSet = new SolutisGridDataSet(); //사용자가 화면상에서 편집한 Row에 대하여 //jqGrid 의 getChangedCells 메서드로 해당 Row가 리턴되지 않도록 초기화 처리한다. //현재 jqGrid에서 초기화 Method를 제공해 주지 않아서 jQuery 와 DOM 구조를 이용하여 처리한다. $("table#" + this.id + " tr[class*=edited]").removeClass("edited"); //jqGrid 하위의 tr 중 edited class 가 있는 tr에 대하여 edited 제거 $("table#" + this.id + " td[class*=dirty-cell]").removeClass("dirty-cell"); //jqGrid 하위의 td 중 dirty-cell class 가 있는 td에 대하여 dirty-cell 제거 // console.log("SolutisGridDataSet 초기화가 정상적으로 처리 됨. ID:" + this.id); }); }, //필수 입력 validation 이 있는 경우에는 헤더에 * 표시 한다. markRequiredAtHeader: function() { this.each(function(){ if(!this.grid) {return;} var ts = this; var colModel = $(ts).jqGrid("getGridParam", "colModel"); var rules, colId; for(var key in colModel){ rules = colModel[key]["solutisrules"]; colId = colModel[key]["name"]; if (rules != undefined && rules.required) { common_jqGridRequiredInput(ts.id, colId); } } }); }, delRowDataEx: function (rowid){ var deleteResult = false; this.each(function(){ if(!this.grid) {return;} var ts = this; //이전 편집중인 Cell의 편집모드를 종료하기 위하여 //아래의 함수 호출.[by Googling] //2개의 Row가 있을 경우 2행을 편집하다가 편집상태로 있으면서 //1행의 삭제 버튼을 눌러 1행을 삭제하면 2행의 편집이 종료되지 않은 상태면서 //첫번째 행으로 변경되므로 jqGrid내부에서 에러가 발생하는 것으로 보임(그리드 다운 현상) //따라서 아래의 로직을 추가하여 편집상태를 종료함. $(ts).jqGrid("editCell", 0, 0, false); var obj = $(ts).jqGrid("getRowData", rowid); //getRowData 는 id 속성 없이 return하여 주므로 셋팅 obj.id = rowid; //삭제전에 해당 rowid가 insert 나 update 에 존재하는지 //확인후 존재한다면 insertedIDs 나 updatedIDs에서 삭제하여 준다. var isInserted = ts._solutisGridDataSet.isInsertedRow(rowid); var isUpdated = ts._solutisGridDataSet.isUpdatedRow(rowid); // console.log("isInserted: " + isInserted); // console.log("isUpdated: " + isUpdated); deleteResult = $(ts).jqGrid("delRowData", rowid); if (deleteResult && !isInserted) { ts._solutisGridDataSet.addDeletedRow(obj); // console.log("삭제목록에 추가 되었음...."); } }); return deleteResult; }, addRowDataEx: function (data, position, srcrowid){ var insertResult = false; this.each(function(){ if(!this.grid) {return;} var ts = this; //이전 편집중인 Cell의 편집모드를 종료하기 위하여 //아래의 함수 호출.[by Googling] //3개의 Row가 있을 경우 3행을 편집하다가 편집상태로 있으면서 //2행의 추가 버튼을 눌러 2~3행 사이에 신규 행을 추가하면 //기존 3행의 편집이 종료되지 않은 상태면서 //4행으로 행이 변경되므로 jqGrid내부에서 에러가 발생하는 것으로 보임(입력값은 화면에 보이는데 서버로는 반영이 안됨) //따라서 아래의 로직을 추가하여 편집상태를 종료함. $(ts).jqGrid("editCell", 0, 0, false); if(!position) {position = "last";} //rowid는 자동생성 되도록 한다. insertResult = $(ts).jqGrid("addRowData", undefined, data, position, srcrowid); if (insertResult) { //현재 Grid의 모든 행의 ID 값을 가지고 온다. var IDs = $(ts).jqGrid("getDataIDs"); var findID; switch(position) { case "first": findID = IDs[0]; break; case "last": findID = IDs[IDs.length - 1]; break; case "before": for(var i=0; i tempObj.maxSuppressNum) { tempObj.maxSuppressNum = parseInt(colModel[index].suppress, 10); } } } //this._suppressCols 배열 구성[각 배열원소는 {name: 컬럼이름, iCol: 컬럼번호} 형태의 객체이다.] ts._suppressCols = new Array(); for(var index=1; index<=tempObj.maxSuppressNum; index++){ //tempObj에 값이 존재할 경우 suppressCols 배열에 넣어준다. if(tempObj[index]){ ts._suppressCols.push(tempObj[index]); } } }); }, //Suppress(Rowspan)처리를 하는 함수(사용자는 이 함수를 호출한다.) composeSuppressRows: function() { this.each(function(){ if(!this.grid) {return;} var ts = this; //suppressCols 정보를 가지고 있는 배열을 구성한다.(최초 한번만 구성) if (!ts._suppressCols) { $(ts).jqGrid("setSuppressCols"); } //suppress정보를 가지고 있는 배열 초기화 ts._suppressInfo = {}; //현재 grid의 전체 rowid를 구한다. var rowIds = $(ts).jqGrid("getDataIDs"); for(var row=0; row 1) { //이전 컬럼(suppress 번호가 낮은)이 span 되었고, //현재 cell의 값이 전행의 값과 같은 경우 span 처리 if (prevColIsSpan && prevRowInfo[ts._suppressCols[col].name].value == currCellValue) { //startRowIndex 값 변경(전행의 값으로 셋팅) currRowInfo[ts._suppressCols[col].name].startRowIndex = prevRowInfo[ts._suppressCols[col].name].startRowIndex; //span row 개수 셋팅 var spanCnt = currentRowIndex - currRowInfo[ts._suppressCols[col].name].startRowIndex + 1; //jQuery를 이용 설명 //$(this).find(tr): 그리드 테이블내에서 tr 개체들을 선택한다. //.eq(iRow): 찾은 tr 중 iRow 번째 tr 개체를 선택한다. //.find("td"): 선택된 tr 하위의 td 개체들을 선택한다. //.eq(iCol): 선택된 td 중 iCol 번째 개체를 선택한다. //현재행은 display: none 처리 $(ts).find("tr").eq(currentRowIndex).find("td").eq(ts._suppressCols[col].iCol).css("display", "none"); //startRowIndex 행의 td는 rowspan 개수를 변경하여 준다. $(ts).find("tr").eq(currRowInfo[ts._suppressCols[col].name].startRowIndex).find("td").eq(ts._suppressCols[col].iCol).attr("rowspan", spanCnt); } else { prevColIsSpan = false; } } } //ts._suppressInfo 개체에 현재행의 컬럼정보 값을 셋팅한다. ts._suppressInfo[currentRowIndex] = currRowInfo; } }); } //============================================================================================= //RowSpan 처리용 함수들 끝 //============================================================================================= , //그리드 업데이트 체크 isDatasetUpdated: function(){ var isUpdated = false; this.each(function(){ if(!this.grid) {return;} var ts = this; var changedCells = jQuery("#"+$(ts)[0].id).jqGrid('getChangedCells'); if($.isEmptyObject(ts._solutisGridDataSet.insertedIDs) && $.isEmptyObject(ts._solutisGridDataSet.updatedIDs) && ts._solutisGridDataSet.deletedList.length <= 0 && changedCells.length <= 0){ isUpdated = false; }else{ isUpdated = true; } }); return isUpdated; } }); /*************************************************************************************************** * JqGrid 부가 사용을 위한 Class 정의 **************************************************************************************************/ //================================= SolutisGridDataSet Class 시작 ======================================== /** * JqGrid의 데이터를 insert, update, delete 트랜잭션별로 * 관리하기 위한 Class */ function SolutisGridDataSet() { /** * 신규 추가된 Row정보를 가지고 있는 배열 * 최종적으로 getGridData 메서드 호출 시 insertedIDs 정보를 * 기초로 하여 배열에 데이터가 구성 된다. */ this.insertedList = new Array(); /** * 수정된 Row정보를 가지고 있는 배열 * 최종적으로 getGridData 메서드 호출 시 updatedIDs 정보를 * 참조 하여 배열에 데이터가 구성 된다. */ this.updatedList = new Array(); /** * 삭제된 Row정보를 가지고 있는 배열 * jqGrid의 delRowDataEx 함수 호출 시 관련Row 정보가 * 아래 배열 정보에 구성된다. */ this.deletedList = new Array(); /** * insert 처리된 Row의 ID 값을 가지고 있는 개체 * key: id, value : 1로 고정. */ this.insertedIDs = {}; /** * update 처리된 Row의 ID 값을 가지고 있는 개체. * key: id, value : 1로 고정. */ this.updatedIDs = {}; } /** * 삭제행의 정보를 삭제행 목록에 add 하여 준다. * @param row jqGrid의 row 값을 가지고 있는 객체 */ SolutisGridDataSet.prototype.addDeletedRow = function(row) { this.deletedList.push(row); }; /** * 수정행의 RowID를 관리객체에 추가한다. * 이때 inserted 되었던 row면 추가 하지 않는다. * @param rowid */ SolutisGridDataSet.prototype.addUpdatedRowId = function(rowid) { if (this.insertedIDs[rowid] == undefined) { this.updatedIDs[rowid] = 1; // console.log("수정이력 updatedIDs에 추가됨.: " + rowid); } }; /** * 신규행의 RowID를 관리객체에 추가한다. * @param rowid */ SolutisGridDataSet.prototype.addinsertedRowId = function(rowid) { this.insertedIDs[rowid] = 1; }; /** * insert 되었던 rowid 인지 확인하고, 되었던 것이라면 ID 목록에서 삭제하도록 한다. * @param rowid row 의 id 값 * @return boolean, true: 추가되었던 Row, false: 추가되지 않은 Row */ SolutisGridDataSet.prototype.isInsertedRow = function(rowid) { if (this.insertedIDs[rowid] == undefined) { return false; } else { delete this.insertedIDs[rowid]; return true; } }; /** * update 되었던 rowid 인지 확인하고, 되었던 것이라면 ID 목록에서 삭제하도록 한다. * @param rowid row 의 id 값 * @return boolean, true: 변경되었던 Row, false: 변경되지 않은 Row */ SolutisGridDataSet.prototype.isUpdatedRow = function(rowid) { if (this.updatedIDs[rowid] == undefined) { return false; } else { delete this.updatedIDs[rowid]; return true; } }; /** * 해당그리드의 update, insert, delete 내역을 각각의 array에 * 구성하여 json type으로 리턴한다. * @param gridObj grid Object * @param dataSetId * @return json Object */ SolutisGridDataSet.prototype.getGridData = function(gridObj, dataSetId) { //insertedList, updatedList 초기화 this.insertedList = new Array(); this.updatedList = new Array(); //현재 편집중인 Row도 getChangedCells 에 반영하기 위하여 //아래의 함수 호출.[by Googling] $(gridObj).jqGrid("editCell", 0, 0, false); //변경된 Row 정보 추출 var changedRows = $(gridObj).jqGrid("getChangedCells"); for (var i=0; i < changedRows.length; i++) { //신규나 수정되었다고 insertedIDs, updatedIDs 에 없는 //Row만 updatedList에 추가 한다. if (this.insertedIDs[changedRows[i].id] == undefined && this.updatedIDs[changedRows[i].id] == undefined) { this.updatedList.push(changedRows[i]); // console.log("updatedList 에 추가됨. rowid: " + changedRows[i].id); } } //insertedIDs, updatedIDs 객체의 property 가 rowid 이므로 //이들 객체의 porperty를 열거하여 List 에 넣어준다. for(var insertedRowid in this.insertedIDs) { var obj = $(gridObj).jqGrid("getRowData", insertedRowid); //getRowData 는 id 속성 없이 return하여 주므로 셋팅 obj.id = insertedRowid; //Array에 추가 this.insertedList.push(obj); //console.log("insertedList Add Insested RowId: " + obj.id); } for(var updatedRowid in this.updatedIDs) { var obj = $(gridObj).jqGrid("getRowData", updatedRowid); //getRowData 는 id 속성 없이 return하여 주므로 셋팅 obj.id = updatedRowid; //Array에 추가 this.updatedList.push(obj); // console.log("updatedList Add Updated RowId: " + obj.id); } //{ // datasetid: { // insertRow : array, // updateRow : array, // deleteRow : array // } //} 형태의 Object 리턴 --> delete가 js 예약어 이므로..'delete' 라고 할수도 있지만 // insert, update, delete 에 모두 Rows를 붙여 주었음. var returnObject = {}; returnObject[dataSetId] = { insertRows: this.insertedList, updateRows: this.updatedList, deleteRows: this.deletedList }; return returnObject; }; //================================== SolutisGridDataSet Class 끝 ============================================== //==================================== SolutisDTO Class 시작 ========================================== function SolutisDTO() { this._postDataObj = {}; //서버로 보낼 자료를 가지고 있는 object } /** * form내의 html element를 json 형태로 변환하여 * DataSet 에 추가한다. * @param dataSetId 서버에서 인지할 form json object ID * @param formJQueryObj Form 의 JQuery Object (i.e $("#formid"))) * @param rowStatus Form 의 데이터 상태(i:신규, u:수정, d:삭제) undefined 및 규정외의 값은 i(신규)로 처리 */ SolutisDTO.prototype.addFormData = function(dataSetId, formJQueryObj, rowStatus) { if (!formJQueryObj.is("form")) { console.error("Form 개체가 아닙니다.....로직확인!!"); return false; } if (formJQueryObj.find("input[name=_menu_code_]").length > 0) { //메뉴코드가 존재한다면 //requestParam에 추가 하여 준다. this._postDataObj.requestParam = $.extend(this._postDataObj.requestParam, {_menu_code_: formJQueryObj.find("input[name=_menu_code_]").val()} ); } //rowStatus 기본값 설정 //데이터 상태(i:신규, u:수정, d:삭제) undefined 및 규정외의 값은 i(신규)로 처리 if (rowStatus != 'u' && rowStatus != 'd') { rowStatus = 'i'; } var formDataObj = {}; formDataObj[dataSetId] = { insertRows: (rowStatus == 'i')?[formJQueryObj.serializeObject()]:[], updateRows: (rowStatus == 'u')?[formJQueryObj.serializeObject()]:[], deleteRows: (rowStatus == 'd')?[formJQueryObj.serializeObject()]:[] }; this._postDataObj = $.extend(this._postDataObj, formDataObj); }; /** * grid에서 구한 gridDataSet을 DataSet 에 추가한다. * @param dataSetId 서버에서 인지할 grid json object ID * @param gridJQueryObj grid 의 JQuery Object (i.e $("#myGrid"))) */ SolutisDTO.prototype.addGridData = function(dataSetId, gridJQueryObj) { this._postDataObj = $.extend(this._postDataObj, gridJQueryObj.jqGrid("getGridData", dataSetId)); }; /** * server에서 dataSet 타입이 아니라 requestParameter로 받을 key-value 데이터가 있을경우 * key-value 의 javascript Object를 인자로 받아 셋팅한다. * 이 함수를 여러번 호출하여 object를 계속 추가 할 수 있으며, 이때 동일한 key 가 존재할 경우에는 * 마지막에 add된 value가 남게 된다. */ SolutisDTO.prototype.addRequestData = function(requestDataObj) { this._postDataObj.requestParam = $.extend(this._postDataObj.requestParam, requestDataObj); }; /** * ajax를 통하여 서버와 통신 할때 복잡한 구조의 개체는 JSON 형태로 * 정의된 문자열을 data 속성에 셋팅하여야 한다. * 따라서 본 함수에서 현재 DTO에 구성된 Javascript Object를 JSON String 으로 변환해 주도록 한다. */ SolutisDTO.prototype.makeJSONString = function() { return JSON.stringify(this._postDataObj); }; //==================================== SolutisDTO Class 끝 ============================================ /*************************************************************************************************** * JqGrid 공통함수 등록 **************************************************************************************************/ // form data to plainObject $.fn.serializeObject = function() { var o = {}; var a = this.serializeArray(); $.each(a, function() { //2014.05.09 김철현 //if (o[this.name]) { 를 if (o[this.name] != undefined) { 로 수정 //checkbox의 '전체' 같은 경우는 value 가 '' 인데 이럴경우 이전 로직으로 하면 //false 가 되어 else 로직을 타게 되서 '' 값이 덮어 씌어져서 사라진다. if (o[this.name] != undefined) { if (!o[this.name].push) { o[this.name] = [o[this.name]]; } o[this.name].push(this.value || ''); } else { o[this.name] = this.value || ''; } }); //_menu_code_ 는 "myForm" 에 정의하고, 조회시에는 searchForm 의 데이터만 //json 화 하여 postData에 담고 있어서 이곳에 아래의 로직을 추가하여 //_menu_code_ 속성이 존재하면 json 객체에 항상 들어갈 수 있도록 한다. //2014.04.23. 김철현 if ($("input[name='_menu_code_']") && !o['_menu_code_']) { o['_menu_code_'] = $("input[name='_menu_code_']").val() || ''; } return o; }; /** * jqgrid pager 처리 * param: gridId - jqgrid id pagerId - pager div id * write: 김재열 * since: 2014.02.10 */ function common_jqGridPager(gridId, pagerId){ $("#"+gridId).jqGrid("navGrid","#"+pagerId,{search:false,edit:false,add:false,del:false,refresh:false}); } /** * 편집 컬럼의 헤더에 아이콘 표시 * @param pGridId grid ID * @param pColId column ID */ function common_jqGridRequiredInput(pGridId, pColId) { var targetId = "div#jqgh_" + pGridId + "_" + pColId; //*이미지를 추가한다. var addHtml = ''; $(targetId).html(addHtml + $(targetId).html()); } /** * jqGrid의 Date formatter 는 20041231 같은 YYYYMMDD 는 처리를 못하므로(ISO표준이 아니라함) * 이를 처리할 수 있는 formatter 및 unformat 를 구현한다. * @param cellvalue 소수점 자리 수 * @param options Object 이며 내부에 colModel Object, gid(gridID), pos, rowId 정보가 있다 * @param rowObject the raw object of the data row - i.e if datatype is json - array. * @return string formatted 된 문자. */ function common_jqGridYmdFormatter(cellvalue, options, rowObject) { //날짜에 대해 입력받을 경우 형식(년도:Y, 년월:YM, 년월일:YMD default:YMD)에 따라 다르게 처리 var dateFormat = options.colModel.dateFormat; var retValue = cellvalue||""; //_orgValue라는 속성을 만들어서 원본값 저장 if (options.colModel._orgValue == undefined) { options.colModel._orgValue = {}; } if(retValue != ""){ //형식이 어긋날 경우 이전값으로 돌리기 위해 변수에 저장 var preValue = options.colModel._orgValue[options.rowId]; //년도만 입력받는 경우 if(dateFormat == "Y"){ if(common_isNumber(retValue, false) && retValue.length == 4) { //원본값 저장 options.colModel._orgValue[options.rowId] = retValue; }else{ //날짜형식에 맞지 않을 경우 이전값을 세팅 //alert('It does not match the date format (YYYYMMDD).'); //날짜형식(YYYYMMDD)에 맞지 않습니다. if(preValue != undefined){ retValue = preValue; }else{ retValue = ""; } } //년월만 입력받는 경우 }else if(dateFormat == "YM"){ if(common_isDateMonth(retValue)) { //원본값 저장 options.colModel._orgValue[options.rowId] = retValue; //yyyy-mm-dd형태로 리턴 retValue = retValue.substring(0, 4)+"-"+retValue.substring(4, 6); }else{ //날짜형식에 맞지 않을 경우 이전값을 세팅 //alert('It does not match the date format (YYYYMMDD).'); //날짜형식(YYYYMMDD)에 맞지 않습니다. if(preValue != undefined){ retValue = preValue.substring(0, 4)+"-"+preValue.substring(4, 6); }else{ retValue = ""; } } //년월일 입력받는 경우.. default }else{ if(common_isDate(retValue)) { //원본값 저장 options.colModel._orgValue[options.rowId] = retValue; //yyyy-mm-dd형태로 리턴 retValue = common_DateMask(retValue, 2); }else{ //날짜형식에 맞지 않을 경우 이전값을 세팅 //alert('It does not match the date format (YYYYMMDD).'); //날짜형식(YYYYMMDD)에 맞지 않습니다. if(preValue != undefined){ retValue = common_DateMask(preValue, 2); }else{ retValue = ""; } } } } return retValue; } /** * common_jqGridYmdFormatter 사용 시 포멧팅 되기 전의 값을 getRowData, getCell에서 * format 되기 전 원본값이 사용되도록 unformat 하여 주는 함수. * @param cellvalue * @param options Object 이며 내부에 colModel Object, rowId 정보가 있다 * @param cell is a jQuery cell object. This object can be used to obtain different things from the cell element * @return string unformated 된 문자. */ function common_jqGridYmdUnFormat(cellvalue, options, cell) { //common_jqGridYmdFormatter 에서 넣어준 원본값 리턴 return options.colModel._orgValue[options.rowId]; } /** * jqGrid의 Number formatter 는 데이터가 342.3456 인 경우 deciamlPlaces가 2이면 * value 자체도 342.34 로 뒤의 자리수가 없어져 보인다. * 원본값을 그대로 보관하기 위하여 custom formatter function을 사용한다. * @param cellvalue * @param options Object 이며 내부에 colModel Object, gid(gridID), pos, rowId 정보가 있다 * @param rowObject the raw object of the data row - i.e if datatype is json - array. * @return string formatted 된 문자. */ function common_jqGridDecimalFormatter(cellvalue, options, rowObject) { var retValue = cellvalue||options.colModel.formatoptions.defaulValue||""; //_orgValue라는 속성을 만들어서 원본값 저장 if (options.colModel._orgValue == undefined) { options.colModel._orgValue = {}; } if(retValue != ""){ var preValue = options.colModel._orgValue[options.rowId]; if(common_isNumber(retValue, true)) { //원본값 저장 options.colModel._orgValue[options.rowId] = retValue; //jqGrid의 number formatter를 그대로 사용하여 return retValue = $.fmatter.util.NumberFormat(retValue, options.colModel.formatoptions); }else{ //숫자가 아닌 경우 이전값 복원$.() if(preValue != undefined){ retValue = $.fmatter.util.NumberFormat(preValue, options.colModel.formatoptions); }else{ retValue = ""; } } } return retValue; } /** * common_jqGridDecimalFormatter 사용 시 포멧팅 되기 전의 값을 getRowData, getCell에서 * format 되기 전 원본값이 사용되도록 unformat 하여 주는 함수. * Number Type * @param cellvalue * @param options Object 이며 내부에 colModel Object, rowId 정보가 있다 * @param cell is a jQuery cell object. This object can be used to obtain different things from the cell element * @return string unformated 된 문자. */ function common_jqGridDecimalUnFormat(cellvalue, options, cell) { //common_jqGridDecimalFormatter 에서 넣어준 원본값 리턴 return options.colModel._orgValue[options.rowId]; } /** * Number Type * @param pDecimalPlaces 소수점 자리 수 * @param pDefaultValue 값이 없을 경우 기본으로 보여줄 값. 없을 경우 * decimalPlaces 값만큼 0.~ 으로 만든다.(ie. deimalPlaces가 3인 경우 0.000) * @return Object : jqGrid의 formatOption 개체 */ function common_jqGridDecimalFormatOptions(pDecimalPlaces, pDefaultValue) { //초기값 셋팅 if (pDefaultValue == undefined) { pDefaultValue = "0."; for(var i=0; i < pDecimalPlaces; i++) { pDefaultValue += "0"; } } return {decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: pDecimalPlaces, defaultValue: pDefaultValue}; } /** * 편집 cell의 배경색을 지정한다. * @param rowId the id of the row * @param val the value which will be added in the cell * @param rawObject the raw object of the data row - i.e if datatype is json - array. * @param cm all the properties of this column listed in the colModel * @param rdata the data row which will be inserted in the row * @return string (style 표현문자) */ function common_jqGridCellEditStyle(rowId, val, rawObject, cm, rdata) { return "style='background-color: #d1efe5;'"; } /** * jqgrid href cell style * write: 김재열 * since: 2014.01.16 */ function common_jqGridCellHrefStyle(rowId, val, rawObject, cm, rdata) { return "style='color:#5D5D5D; cursor: pointer;'"; } /* * custom tooltip */ function common_jqGridTooltipCustom(rowId, val, rawObject, cm, rdata) { if(val == "" || val == " "){ return; } var text = val.split("|"); var strTooltip = ""; for(var i=0; i "0") return "class='editable' "; else return "style='background-color:#F6FAF0;color:#ff0000;'"; } // 190827 function common_jqGridCellEllipsis(rowId, val, rawObject, cm, rdata) { return "class='ui-cell-ellipsis'"; // return "width: 100%;white-space: nowrap;text-overflow: ellipsis;"; } function common_jqGridCellEllipsisHand(rowId, val, rawObject, cm, rdata) { return "class='ui-cell-ellipsis-hand'"; } /** * 조회 후 데이터 매핑 이전에 발생하는 것으로 확인되며 공통 처리를 하는 용도로 함수 사용 * --->TODO 김철현 제거 대상임. * @write: 김재열 * @param data : the data is formatted depended on the value of the datatype parameter * @param status : a string describing the type of error * @param xhr : XMLHttpRequest object * @since: 2014.02.13 */ function common_jqGridBeforeProcessing(data, status, xhr) { //그리드 번호 타이틀 - 이렇게 코딩 하면 jqGrid의 destroyGroupHeader 함수 처리시 에러발생 //추후 제대로된 로직 찾기전까진 주석 처리. //$("th[id$='_rn']").text('Number'); } //===============신규 rowspan으로 모두 변경이 되면 이부분 삭제 할것 시작============================ /** * data rowspan * @write: 김재열 * @param idx : 컬럼마다 다르게 준다 1, 2, 3,.... * @param gridObj : this * @since: 2014.02.13 * modify : [2014.03.03 신명진] rowspan시 앞의 컬럼에 종속되게..... */ var common_jqPrevCell; var spanFlag = true; //앞의 컬럼이 rowspan 되었는지 여부 function common_jqGridRowspanAttr(rowId, val, rowObject, cm, rdata, idx, gridObj){ try{ if(!common_jqPrevCell[idx]){ common_jqPrevCell[idx] = { cellId: undefined, value: undefined }; } } catch(e){ common_jqPrevCell = new Array(); common_jqPrevCell[idx] = { cellId: undefined, value: undefined }; } var result; if(idx == 1){ spanFlag = true; } if (common_jqPrevCell[idx].value == val&&spanFlag) { result = ' style="display: none" rowspanid="' + common_jqPrevCell[idx].cellId + '"'; } else { var cellId = gridObj.id + '_row_' + rowId + '_' + cm.name; result = 'style="background-color:white;" rowspan="1" id="' + cellId + '"'; common_jqPrevCell[idx] = { cellId: cellId, value: val }; spanFlag = false; } return result; } // "style='background-color:#F6FAF0;color:#666;'"; 추가되어야 함... function common_jqGridRowspanReanonly(rowId, val, rowObject, cm, rdata, idx, gridObj){ try{ if(!common_jqPrevCell[idx]){ common_jqPrevCell[idx] = { cellId: undefined, value: undefined }; } } catch(e){ common_jqPrevCell = new Array(); common_jqPrevCell[idx] = { cellId: undefined, value: undefined }; } var result; if(idx == 1){ spanFlag = true; } if (common_jqPrevCell[idx].value == val&&spanFlag) { result = ' style="display: none" rowspanid="' + common_jqPrevCell[idx].cellId + '"'; } else { var cellId = gridObj.id + '_row_' + rowId + '_' + cm.name; result = 'style="background-color:#F6FAF0;color:#666;" ' + ' rowspan="1" id="' + cellId + '"'; common_jqPrevCell[idx] = { cellId: cellId, value: val }; spanFlag = false; } return result; } function common_jqGridRowspanHyper(rowId, val, rowObject, cm, rdata, idx, gridObj){ try{ if(!common_jqPrevCell[idx]){ common_jqPrevCell[idx] = { cellId: undefined, value: undefined }; } } catch(e){ common_jqPrevCell = new Array(); common_jqPrevCell[idx] = { cellId: undefined, value: undefined }; } var result; if(idx == 1){ spanFlag = true; } if (common_jqPrevCell[idx].value == val&&spanFlag) { result = ' style="display: none" rowspanid="' + common_jqPrevCell[idx].cellId + '"'; } else { var cellId = gridObj.id + '_row_' + rowId + '_' + cm.name; result = 'style="background-color:#F6FAF0;color:#5D5D5D; cursor: pointer;" ' + ' rowspan="1" id="' + cellId + '"'; common_jqPrevCell[idx] = { cellId: cellId, value: val }; spanFlag = false; } return result; } /** * data rowspan 2 * write: 김재열 * since: 2014.02.13 */ function common_jqGridRowspanComplete(grid) { $('td[rowspan="1"]', grid).each(function () { var spans = $('td[rowspanid="' + this.id + '"]', grid).length + 1; if (spans > 1) { $(this).attr('rowspan', spans); } }); common_jqPrevCell = new Array(); } //===============신규 rowspan으로 모두 변경이 되면 이부분 삭제 할것 끝============================= /** * 그리드 버튼 이미지 * write: 김재열 * since: 2014.02.25 */ function common_jqGridImage(imgName) { if (imgName == undefined || imgName == null || imgName.length < 1) return ""; return ''; } /** * 그리드 업로드된 이미지 * write: SOLUTIS * since: 2019.08.19 */ function kncap_jqGridImage(imgName) { if (imgName == undefined || imgName == null || imgName.length < 1) return ""; return ''; } function kncap_jqGridInnerImage(imgName) { if (imgName == undefined || imgName == null || imgName.length < 1) return ""; return ''; } /** * 그리드에서 datepicker 사용하기위하여 editoptions>dataInit 에 사용할 리스너 함수 * @param elem datepicker 이벤트가 발생한 element(Edit시의 input) * @since: 2014.07.17 * @write: 김철현 */ function common_jqGridDatepicker(elem){ $(elem).datepicker( { //그리드의 입력모드에서는 YYYYMMDD 형태 임. dateFormat: "yymmdd" } ); }