IB Sheet 8 Examples

숫자, 날짜 포맷

HTML

<link rel="stylesheet" href="https://demo.ibleaders.com/ibsheet/v8/samples/customer-sample/assets/css/style.css">
<!-- ibsheet css -->
<link rel="stylesheet" href="https://demo.ibleaders.com/ibsheet/v8/samples/customer-sample/assets/ibsheet/css/default/main.css"/>
<link rel="stylesheet" href="https://demo.ibleaders.com/ibsheet/v8/samples/customer-sample/assets/ibsheet/css/compatible/light/main.css"/>

<!--  ibsheet 필수 js -->
<script src="https://demo.ibleaders.com/ibsheet/v8/samples/customer-sample/assets/ibsheet/ibleaders.js"></script>
<script src="https://demo.ibleaders.com/ibsheet/v8/samples/customer-sample/assets/ibsheet/ibsheet.js"></script>
<script src="https://demo.ibleaders.com/ibsheet/v8/samples/customer-sample/assets/ibsheet/locale/ko.js"></script>

<!--  ibsheet 선택/추가 js -->
<script src="https://demo.ibleaders.com/ibsheet/v8/samples/customer-sample/assets/ibsheet/plugins/ibsheet-common.js"></script>
<script src="https://demo.ibleaders.com/ibsheet/v8/samples/customer-sample/assets/ibsheet/plugins/ibsheet-dialog.js"></script>
<script src="https://demo.ibleaders.com/ibsheet/v8/samples/customer-sample/assets/ibsheet/plugins/ibsheet-excel.js"></script>
<div class='ibsheet-wrap' id='descFunc'>
<b>
[ Type Int -> Float 변경 ]
</b><br>
setAttribute 를 통해 Type을 바꾸고, <b>Format 변경</b>도 함께 해주셔야 합니다.<br>기존의 Int Type 설정이 남아있기 때문에 소수점이 표현되지 않습니다.<br>

<button onclick='ib.sampleBtn(this)' class='mgr10'>Type변경</button><hr/>
<button onclick='ib.sampleBtn(this)' class='mgr10'>Format변경</button><hr/>
</div>
<div style='height:calc(100% - 20px)'><div id='sheetDiv' style='width:100%;height:100%'></div></div>

JavaScript

var ib = ib||{};
ib = {
//시트 초기화 구문
'init':{
  //공통기능 설정 부분
  "Cfg": {
    "SearchMode": 0,
    "MaxPages": 3,
    "SuppressMessage": 3,
    "HeaderMerge": 3,
    "FitWidth": true
  },
  //틀고정 좌측 컬럼 설정
  "LeftCols": [
    {"Type": "Int","Width": 50,"Align": "Center","Name": "SEQ"}
  ],
  //중앙(메인) 컬럼 설정
  "Cols": [
    {"Header": "회사명","Type": "Text","Name": "sCorp","Width": "100","Align": "Center","CanEdit": 1},
    {"Header": "Int","Type": "Int","Name": "sPay","Width": "100","Align": "Right","CanEdit": 1}
  ]
},
//시트 이벤트
'event':{
  onRenderFirstFinish: function(evt) {
    evt.sheet.loadSearchData(ib.data);
  }
},
//시트객체 생성
'create':function () {
    var options = this.init;

    options.Events = this.event;
    IBSheet.create({
      id: 'sheet', // 생성할 시트의 id
      el: 'sheetDiv', // 시트를 생성할 Dom 객체 및 id
      options: options, // 생성될 시트의 속성
    });
  },
//화면 기능
'sampleBtn':function () {

  switch (arguments[0].innerText) {
    case 'Type변경':
   	  var frow = sheet.getFirstRow();
      sheet.setAttribute(frow, 'sPay', 'Type', 'Float');
      break;
    case 'Format변경':
    	var frow = sheet.getFirstRow();
      sheet.setAttribute(frow, 'sPay', 'Format', '#,##0.##');
      break;
  }
},
//조회 데이터
 'data': [{
    "sCorp": "삼성전자",
    "sPay": "6290.9301"    
  }]
}
ib.create();