LoginSignup
0
0

Wijimoのフロント画面の実装Tip集

Posted at

Wijmoのフロントの画面を作成するうえでの備忘録です。

チェックボックスでグリッドの中身を編集制御する画面

index.html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>編集権限があるグリッドの実装</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="node_modules/systemjs/dist/system.src.js"></script>
    <script src="systemjs.config.js"></script>
    <script>
        System.import('./src/app');
    </script>
</head>
<body>
    <h3>チェックボックスで編集可または不可を実装する</h3>
    <div class="container-fluid">
      <div id="theGrid">
      </div>
    </div>
</body>
</html>
index.js
import 'bootstrap.css';
import '@grapecity/wijmo.styles/wijmo.css';
import './styles.css';
import * as wjGrid from '@grapecity/wijmo.grid';
//
document.readyState === 'complete' ? init() : window.onload = init;
//
function init() {
    //
    // create some random data
    var samples = 'サンプル1,サンプル2,サンプル3,サンプル4,サンプル5,'.split(',');
    var data = [];
    for (var i = 0; i < samples.length; i++) {
        data.push({
            id: i,
            sample: samples[i],
            productsales: Math.random() * 10000,
            expenses: Math.random() * 5000,
            overdue: (i + 1) % 4 == 0
        });
    }
    //
    // default clipboard behavior
    var theGrid = new wjGrid.FlexGrid('#theGrid', {
        itemsSource: data,
        columns: [
            { binding: 'id', header: 'ID', width: 50, isReadOnly: true },
            { binding: 'sample', header: 'サンプル名', isRequired: true },
            { binding: 'productsales', header: '商品売上', isRequired: false },
            { binding: 'expenses', header: '費用', isRequired: false },
            { binding: 'overdue', header: '編集可または不可' }
        ],
        beginningEdit: function (s, e) {
            let item = e.getRow().dataItem, binding = e.getColumn().binding;
            if (item.overdue && binding != 'overdue') { // prevent editing overdue items
                e.cancel = true;
            }
        }
    });
}


index.css
.wj-flexgrid {
  max-height: 200px;
  margin-bottom: 12px;
}

body {
  margin-bottom: 24px;
}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0