javascript - 可手动设置自定义选项卡顺序

标签 javascript handsontable

我有一个手动网格( 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
  });

});

MY CODE

最佳答案

使用上面 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/

相关文章:

javascript - JavaScript 中的 [[ param1, param2 ... ]] 结构是什么?

javascript - 在 Handsontable 中,计算无法使用 AJAX 进行自定义单元格渲染

javascript - Flatpickr onDayCreate 添加类

javascript - Intl.NumberFormat 与 maximumFractionDigits

javascript - 带你的href视频

HandsonTable 未渲染所有行

javascript - 在响应式网站上使用javascript修改字体大小

javascript - 如何在 javascript 函数(如 Node 或 Express HTTP 函数)中接收默认参数?

javascript - Handsontable 自动完成弹出/显示在单元格上方

javascript - 如何获取 AngularJS ngHandsontable 的句柄