var datagrid; var SBGridProperties = {}; function createGrid(){ SBGridProperties.parentid = 'SBGridArea'; SBGridProperties.id = 'datagrid'; SBGridProperties.jsonref = 'fData'; SBGridProperties.rowheader = ['seq','update']; SBGridProperties.selectmode = 'free'; SBGridProperties.fixedrowheight = 50; SBGridProperties.extendlastcol = 'scroll'; SBGridProperties.columns = [ {caption : ['학원명\n(@학원)'], ref : 'academy', width : '150px', style : 'text-align:left', type : 'input', format : {type:'string', rule:'@"학원"'} }, {caption : ['설립자\n(@님)'], ref : 'name', width : '80px', style : 'text-align:center', type : 'input', format : {type:'string', rule:'@"님"'}}, {caption : ['설립일\n(yyyy/mm/dd)'], ref : 'startDay', width : '130px', style : 'text-align:center', type : 'datepicker', format : {type:'date', rule:'yyyy/mm/dd', origin : 'yyyymmdd'}, typeinfo :{displayui:true}}, {caption : ['휴대전화\n(000-0000-0000)'], ref : 'phone', width : '170px', style : 'text-align:center', type : 'input', format : {type:'string', rule:'000-0000-0000'}}, {caption : ['수강\n과목'], ref : 'curriculum',width : '60px', style : 'text-align:center', type : 'input'}, {caption : ['강의시간\n(HH:mm)'], ref : 'startTime' ,width : '110px', style : 'text-align:center', type : 'input', format : {type:'date', rule:'HH:mm', origin : 'HHmm' }}, {caption : ['수강료\n(#,###)'], ref : 'pay', width : '100px', fixedstyle:'background-color:yellow', style : 'text-align:right', type : 'input', format : {type:'number', rule:'#,###'}, datatype : 'number'}, {caption : ['카드번호\n(customFormat)'], ref : 'cardNum', width : '130px', style : 'text-align:left', type : 'input', format : {type:'custom', callback : fnCustom}} ]; datagrid = _SBGrid.create(SBGridProperties); }; //custom Format 설정 function fnCustom(strData){ var strFormatData = ''; if(strData.length > 0){ if(strData.length == 16){ strFormatData = strData.substring(0,4) + '-' +strData.substring(4,8) + '-' +strData.substring(8,12) + '-' + strData.substring(12,16); }else if(strData.length == 15){ strFormatData = strData.substring(0,4) + '-' +strData.substring(4,8) + '-' +strData.substring(8,12) + '-' + strData.substring(12,15); }else{ for(var i=0; i< strData.length; i++){ if(i > 0 && i%4 == 0){ strFormatData = strFormatData + '-'; } strFormatData = strFormatData + strData[i]; } } } return strFormatData ; }