How to disable adding new rows/cols in handsontable?

PolGraphic picture PolGraphic · May 17, 2014 · Viewed 8.5k times · Source

First of all, there is an well-known bug with handsontable (which is a great piece of code anyway), mentioned by e.g. user tezhm, on official github issues list for handsontable:

When selecting a cell on the last row of a table and drag-selecting below the row into an area outside of the table, the scroll viewport is triggered causing a malfunction of the view. This can be recreated using the demo tables.

Because of it, I decided to either turn off scrollbars completely or disable adding new rows/cols.

But how to disable adding new rows/cols in handsontable?

Alternatively, how to disable scrolling in handsontable?

Answer

PostureOfLearning picture PostureOfLearning · May 18, 2014

To disable adding new rows/columns, set the following options:

minSpareRows: 0,
minSpareCols: 0

If you are using a context menu, you can disable the functionality with:

contextMenu: ["undo", "redo"]

Another option could be to set maxRows to the number of rows in your data and maxCols to the number of columns in your data. Note: if you are using the columns option, maxCols will be ignored.

maxRows: data.numberOfRows,
maxCols: data.numberOfColumns