SpreadJS 支持以下平台的触摸操作。
Desktop: Windows--Edge, Chrome, Firefox, Opera
Tablet PC: iPad--Chrome, Safari; Android Pad--Chrome; Surface--Edge
Mobile: Android--Chrome; Windows Phone: Edge
你可以调用 useTouchLayout 属性来获取或者设置是否使用触摸布局来呈现 Spread 部件。在触摸布局下,控件更容易进行触摸操作。
SpreadJS 在触摸模式下提供了很多功能,包括滚动,缩放,选择,调整大小,拖拽填充,组,单元格类型,自动调整,编辑,工作表选项卡和工具栏。
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;
};
};
<!doctype html>
<html style="height:100%;font-size:14px;">
<head>
<meta name="spreadjs culture" content="zh-cn" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css"
href="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets/styles/gc.spread.sheets.excel2013white.css">
<script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/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$/zh/purejs/node_modules/@grapecity-software/spread-sheets-resources-zh/dist/gc.spread.sheets.resources.zh.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">Enable Touch</label>
</div>
<hr>
<div id="ss" class="sample-spreadsheets"></div>
</div>
</body>
</html>
.sample-tutorial {
position: relative;
height: 100%;
overflow: hidden;
}
.sample-spreadsheets {
width: 100%;
height: calc(100% - 70px);
overflow: hidden;
float: bottom;
}
.options-container {
float: top;
width: 100%;
padding: 12px;
height: 50px;
box-sizing: border-box;
background: #fbfbfb;
overflow: auto;
}
.option-row {
font-size: 14px;
padding: 5px;
margin-top: 10px;
}
label {
margin-bottom: 6px;
}
input {
padding: 4px 6px;
}
body {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}