概要と基本的な使い方

SpreadJSは、タッチ操作をサポートします。つまり、アプリケーションがモバイル機器などのタッチ操作対応機器で使用できるようになることを意味し、提供するコンテンツがさまざまな手段でアクセス可能となります。

SpreadJSの表示にタッチレイアウトを使用するかどうかを取得および設定するには、useTouchLayoutオプションを使用します。タッチレイアウトを適用したコントロールでは、タッチ操作が容易になります。 SpreadJSのタッチモードでは、スクロール、ズーム、選択、サイズ変更、ドラッグフィル、グループ化、セル型、自動調整、フィルタ、編集、タブストリップ、ツールストリップなど、多数の機能がサポートされます。 CSSクラスsjs-touch-selection-indicatorのwidthプロパティを使用して、タッチ選択インジケーターのサイズをカスタマイズできます。既定のサイズは16pxで、有効な範囲は8pxから32pxです。例:
window.onload = function () { var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss")); spread.options.useTouchLayout = true; var sd = dataSource; var sheet = spread.getActiveSheet(); if (sd.length > 0) { sheet.setDataSource(sd); } sheet.setColumnWidth(0, 160); sheet.setColumnWidth(1, 70); sheet.setColumnWidth(2, 90); sheet.setColumnWidth(3, 110); sheet.setColumnWidth(4, 80); sheet.setColumnWidth(6, 110); document.getElementById('useTouchLayout').onclick = function (e) { spread.options.useTouchLayout = e.target.checked; }; document.getElementById('indicatorSize').oninput = function (e) { var size = e.target.value; document.getElementById('indicatorSizeValue').textContent = size; updateIndicatorSize(size); spread.refresh(); }; }; function updateIndicatorSize(size) { var styleEl = document.getElementById('touch-indicator-style'); if (!styleEl) { styleEl = document.createElement('style'); styleEl.type = 'text/css'; styleEl.id = 'touch-indicator-style'; document.head.appendChild(styleEl); } styleEl.textContent = '.sjs-touch-selection-indicator { width: ' + size + 'px; }'; }
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta name="spreadjs culture" content="ja-jp" /> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/ja/purejs/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <script src="$DEMOROOT$/ja/purejs/node_modules/@mescius/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/data/data.js" type="text/javascript"></script> <script src="$DEMOROOT$/ja/purejs/node_modules/@mescius/spread-sheets-resources-ja/dist/gc.spread.sheets.resources.ja.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/js/license.js" type="text/javascript"></script> <script src="app.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="styles.css"> </head> <body> <div class="sample-tutorial"> <div class="options-container"> <input type="checkbox" id="useTouchLayout" checked="checked"> <label for="useTouchLayout">タッチを有効にする</label> <div class="option-row"> <label for="indicatorSize" class="indicator-size-label">タッチ選択インジケーターのサイズ: <span id="indicatorSizeValue">16</span>px</label> <input type="range" id="indicatorSize" min="8" max="32" value="16"> </div> </div> <hr> <div id="ss" class="sample-spreadsheets"></div> </div> </body> </html>
.sample-tutorial { position: relative; height: 100%; overflow: hidden; display: flex; flex-direction: column; } .sample-spreadsheets { width: 100%; flex: 1; overflow: hidden; } hr { width: 100%; border: none; border-top: 1px solid #ccc; margin: 8px 0; flex-shrink: 0; } .options-container { width: 100%; padding: 12px; box-sizing: border-box; background: #fbfbfb; } .option-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 14px; padding: 5px; } #indicatorSize { width: 200px; padding: 0; } .indicator-size-label { display: inline-block; width: 220px; } label { margin-bottom: 6px; } input { padding: 4px 6px; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; }