Wijmo FlexGrid セルの任意の場所をクリックしてチェック

by Wijmo5_jp

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.grapecity.com/wijmo/5.latest/styles/wijmo.min.css">
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/cultures/wijmo.culture.ja.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.grid.min.js"></script>
<div class="container-fluid">
  <label><input type="checkbox" id="bigCheckboxes" checked> セルの任意の場所をクリックしてチェック</label><br>
  <div id="flexGrid"></div>
</div>

CSS

body {
  margin: 50px 0;
}

JavaScript

document.readyState === 'complete' ? init() : window.onload = init;
function init() {
  var flexGrid = new wijmo.grid.FlexGrid('#flexGrid', {
    itemsSource: getData(5),
    columns: [
      { binding: '値引', width: 80 },
      { binding: 'No', width: 80 },
      { binding: '商品名', width: 200 },
      { binding: '受注日', width: 120 },
      { binding: '金額', format: 'c', width: 100 }
    ],
    bigCheckboxes: true
  });
  document.getElementById('bigCheckboxes').addEventListener('change', function (e) {
    flexGrid.bigCheckboxes = e.target.checked;
  });
}

var productNames = ['果汁100%オレンジ', '果汁100%グレープ', '果汁100%レモン', '果汁100%ピーチ', 'コーヒーマイルド', 'コーヒービター', 'コーヒーミルク', 'ピリピリビール', 'オタル白ラベル', 'バードワイン'];
function random(max, min) {
  if (!min) min = 0;
  return Math.floor(Math.random() * (max - min)) + min;
}
function randomDate() {
  let date = new Date((new Date()).getFullYear() - 5, 3, 1);
  return wijmo.DateTime.addDays(date, random(365 * 5));
}
function getData(length) {
  let data = [];
  for (let i = 0; i < length; i++) {
    data.push({
      No: i,
      商品名: productNames[random(productNames.length)],
      受注日: randomDate(),
      金額: random(99, 1) * 100,
      値引: random(3) == 0
    });
  }
  return data;
}