1
votes

I'm trying to use two editable slickgrid instances as a data entry form, and I'd like to be able to tab from the last cell of the first grid to the first cell of the second grid, but the following doesn't seem to work. What am I missing?

  firstGrid.onKeyDown.subscribe(function(event) {
    if (event.keyCode === 9 && event.shiftKey === false) {
      if (firstGrid.getActiveCell().cell === lastCol) {
        firstGrid.commitCurrentEdit();
        secondGrid.gotoCell(0, 0, true);
      }
    }
  });

Actually if I hit tab three times it works, but I would really like it to work with a single keypress.

Note that the first grid has only one row, which is why I don't have to test the row.

1

1 Answers

3
votes

First off, commitCurrentEdit is not a method on the grid, and it turns out not to be necessary. What's needed is to prevent (the grid's) other handlers from interfering by calling the (jquery) event object's stopImmediatePropagation method:

firstGrid.onKeyDown.subscribe(function(event) {
  if (event.keyCode === 9 && event.shiftKey === false) {
    if (firstGrid.getActiveCell().cell === lastCol) {
      secondGrid.gotoCell(0, 0, true);
      event.stopImmediatePropagation();
    }
  }
});