How to disable adding new rows/cols in handsontable?
Asked Answered
M

3

8

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?

Misprize answered 17/5, 2014 at 15:42 Comment(0)
S
15

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
Spinthariscope answered 18/5, 2014 at 10:17 Comment(0)
M
3

I have tried

minSpareRows: 0,
minSpareCols: 0

But no luck :(.

Finally, I tried something like the following:

afterCreateRow: function (index, numberOfRows) {
                    data.splice(index, numberOfRows);
                }

It did the work :)

Monastery answered 11/10, 2015 at 12:29 Comment(1)
That's another way to go, I guess. Thank you.Misprize
R
3

Use below options , this works for me..

fillHandle: {
      direction: 'vertical',
      autoInsertRow: false,
    }
Rede answered 8/5, 2018 at 10:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.