指定最大高度时,Handson表不会自动滚动到新的备用行。即使使用旧版本也会出现这种情况:
document.addEventListener("DOMContentLoaded", function() {
function getCarData() {
return [
["Nissan", 2012, "black", "black"],
["Nissan", 2013, "blue", "blue"],
["Chrysler", 2014, "yellow", "black"],
["Volvo", 2015, "white", "gray"]
];
}
var
data = [
['', 'Kia', 'Nissan', 'Toyota', 'Honda'],
['2013', 10, 11, 12, 13],
['2014', 20, 11, 14, 13],
['2015', 30, 15, 12, 13]
],
container = document.getElementById('example1'),
hot;
hot = Handsontable(container, {
data: data,
minSpareRows:1,
height : 130,
rowHeaders: true,
colHeaders: true
});
hot.selectCell(2,2);
function bindDumpButton() {
if (typeof Handsontable === "undefined") {
return;
}
Handsontable.Dom.addEvent(document.body, 'click', function (e) {
var element = e.target || e.srcElement;
if (element.nodeName == "BUTTON" && element.name == 'dump') {
var name = element.getAttribute('data-dump');
var instance = element.getAttribute('data-instance');
var hot = window[instance];
console.log('data of ' + name, hot.getData());
}
});
}
bindDumpButton();
});

<!-- Copied from http://docs.handsontable.com/0.15.1/demo-highlighting-current.html -->
</style><!-- Ugly Hack due to jsFiddle issue -->
<script src="http://docs.handsontable.com/0.15.1/scripts/jquery.min.js"></script>
<script src="http://docs.handsontable.com/0.15.1/bower_components/handsontable/dist/handsontable.full.js"></script>
<link type="text/css" rel="stylesheet" href="http://docs.handsontable.com/0.15.1/bower_components/handsontable/dist/handsontable.full.min.css">
&#13;
<div id="example1" class="hot handsontable"></div>
&#13;
答案 0 :(得分:0)
你的问题是什么?你想要一种滚动到底部的方法吗?您可以使用container.scrollTo(container.height)
,其中container.height
是container
的高度; container.height
可能不是正确的语法,我忘了它是什么。