滚动条由滚动箭头按钮, 滚动滑块以及滚动滑块容器组成。Spread 的滚动条支持以下行为: 点击滚动箭头按钮滚动,拖拽滚动滑块滚动,以及点击滚动滑块和滚动箭头按钮之间的区域进行滚动。这些动作将促成以下滚动效果:
每点击滚动箭头按钮一次将会滚动表单中的一行或者一列。
上下(或左右)拖动滚动滑块将平滑上下(或左右)滚动表单行列。
每点击滚动滑块与滚动箭头按钮中间区域一次将会滚动表单一页。
你可以设置 showVerticalScrollbar 和 showHorizontalScrollbar 选项来控制是否显示滚动条。
SpreadJS 在你拖拽滚动滑块过程中可以显示滚动提示条。你可以设置 showScrollTip 选项来设置以何种方式显示滚动提示条。在拖拽滚动滑块的过程中,滚动提示条将显示当前可见区域的最顶行和最左列的索引值。
你可以设置 scrollbarMaxAlign 和 scrollbarShowMax 选项来限制滚动的区域。
scrollbarMaxAlign: 滚动条是否对齐视图中表单的最后一行或一列。
scrollbarShowMax: 是否基于表单全部的行列总数显示滚动条。
你可以使用 scrollIgnoreHidden 选项来控制滚动条是否忽略隐藏的行或者列。
以下信息将被视为隐藏:
行高为 0
列宽为 0
行/列的 visible 属性为 false
被收起的分组行列
被筛选掉的行
window.onload = function() {
var spread = new GC.Spread.Sheets.Workbook(_getElementById('ss'), { sheetCount: 1 });
initSpread(spread);
};
function initSpread(spread) {
/* Binding settings */
_getElementById('showHorizontalScrollbar').addEventListener('change', function() {
spread.options.showHorizontalScrollbar = this.checked;
});
_getElementById('showVerticalScrollbar').addEventListener('change', function() {
spread.options.showVerticalScrollbar = this.checked;
});
_getElementById('scrollbarMaxAlign').addEventListener('change', function() {
spread.options.scrollbarMaxAlign = this.checked;
});
_getElementById('scrollbarShowMax').addEventListener('change', function() {
spread.options.scrollbarShowMax = this.checked;
});
_getElementById('optShowScrollTip').addEventListener('change', function() {
var result = parseInt(this.value);
spread.options.showScrollTip = result;
});
_getElementById('scrollIgnoreHidden').addEventListener('change', function() {
spread.options.scrollIgnoreHidden = this.checked;
});
var sheet = spread.getActiveSheet();
}
function _getElementById(id){
return document.getElementById(id);
}
<!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 id="ss" class="sample-spreadsheets"></div>
<div class="options-container">
<p> Change the different properties below to see how it affects the different aspects of the workbook
scrollbars.</p>
<div class="option-row">
<label>showScrollTip:</label>
<select id="optShowScrollTip">
<option value="0" selected="selected">None</option>
<option value="1">Horizontal</option>
<option value="2">Vertical</option>
<option value="3">Both</option>
</select>
</div>
<hr />
<div class="option-row">
<input type="checkbox" id="showHorizontalScrollbar" checked="checked" />
<label for="showHorizontalScrollbar">Horizontal Scrollbar</label>
</div>
<label>Set this to have the horizontal scrollbar show.</label>
<div class="option-row">
<input type="checkbox" id="showVerticalScrollbar" checked="checked" />
<label for="showVerticalScrollbar">Vertical Scrollbar</label>
</div>
<label>Set this to have the vertical scrollbar show.</label>
<div class="option-row">
<input type="checkbox" id="scrollbarMaxAlign" />
<label for="scrollbarMaxAlign">Scrollbar Max Align</label>
</div>
<label>Set this to restrict the scrolling to the max number of rows/columns.</label>
<div class="option-row">
<input type="checkbox" id="scrollbarShowMax" checked="checked" />
<label for="scrollbarShowMax">Scrollbar Show Max</label>
</div>
<label>Set this to have the scrollbar show the max scroll space.</label>
<hr />
<div class="option-row">
<input type="checkbox" id="scrollIgnoreHidden" />
<label for="scrollIgnoreHidden">Scroll Ignore Hidden</label>
</div>
<label>Set this to ignore the hidden rows or columns.</label>
</div>
</div>
</body>
</html>
.sample-tutorial {
position: relative;
height: 100%;
overflow: hidden;
}
.sample-spreadsheets {
width: calc(100% - 280px);
height: 100%;
overflow: hidden;
float: left;
}
.options-container {
float: right;
width: 280px;
padding: 12px;
height: 100%;
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;
}
input[type=button] {
margin-top: 6px;
display: block;
}
hr {
border-color: #fff;
opacity: .2;
margin-top: 20px;
}
body {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}