Handsontable: Prevent new rows on paste?

Created on 3 Dec 2014  路  3Comments  路  Source: handsontable/handsontable

I'm using handsontable to edit a table with a pre-determined number of rows.

Unfortunately, when I paste a number of rows larger than the number of rows, new rows are automatically added.

e.g.: Pasting a 15-line clipboard in a 10-line handsontable causes 5 new lines to be inserted

How can I disable this behavior and truncate the paste instead?

Thanks!

Question

Most helpful comment

@paulo-raca I was looking for a similar option. The easiest thing you can do now is to set the maxRows option to your predetermined number of rows:

var table = new Handsontable(element, {
  maxRows: 10
});

Another option would be implementing an beforeCreateRow event (similar to afterCreateRow) that can return false or throw an exception to block the new row(s). That would be more work though.

All 3 comments

@paulo-raca I was looking for a similar option. The easiest thing you can do now is to set the maxRows option to your predetermined number of rows:

var table = new Handsontable(element, {
  maxRows: 10
});

Another option would be implementing an beforeCreateRow event (similar to afterCreateRow) that can return false or throw an exception to block the new row(s). That would be more work though.

maxRows is a good idea, thanks!

maxRows: mydata.length worked liked a charm for me. Thanks donmccurdy.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jlrosenberg24 picture jlrosenberg24  路  3Comments

budnix picture budnix  路  3Comments

vikashait picture vikashait  路  3Comments

wszymanski picture wszymanski  路  3Comments

AMBudnik picture AMBudnik  路  3Comments