我有一个手动网格( HandsonTable )并且想要限制导航 仅前两列(A,B)。所以当用户从 A1 开始并且 使用选项卡,它将导航到 B1、A2、B2、A3、B3 等,当到达表格末尾时,将备份到 A1。
有办法做到这一点吗?
$(document).ready(function () {
var container = document.getElementById('basic_example');
var data = function () {
return Handsontable.helper.createSpreadsheetData(100, 12);
};
var hot = new Handsontable(container, {
data: data(),
height: 400,
colHeaders: true,
rowHeaders: true,
stretchH: 'all',
columnSorting: true,
contextMenu: true
});
});
最佳答案
使用上面 mpuraria 提供的链接并使其正常工作。使用 Tab 键时,导航顺序仅限于前两列。 jsfiddle .
$(document).ready(function () {
var container = document.getElementById('basic_example');
var data = function () {
return Handsontable.helper.createSpreadsheetData(10, 9);
};
var hot = new Handsontable(container, {
data: data(),
height: 400,
colHeaders: true,
rowHeaders: true,
stretchH: 'all',
columnSorting: true,
contextMenu: true
});
Handsontable.Dom.addEvent(document.body, 'keydown', function(e) {
if (e.keyCode === 9) {
e.stopPropagation();
var selection = hot.getSelected();
var rowIndex = selection[0];
var colIndex = selection[1];
//rowIndex++;
colIndex++;
if (colIndex > 1) {
rowIndex++;
colIndex = 0;
}
hot.selectCell(rowIndex,colIndex);
}
});
});
关于javascript - 可手动设置自定义选项卡顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31422255/