Copy multi row and paste on the last row of table

Tags: #<Tag:0x00007efc64866548>

Hi, How can I Copy multi row and paste on the last row of another table, but not insert new row to the pasted row and only copy the top multi rows to the pasted table?
http://jsfiddle.net/api/post/library/pure/

For example: I copy row 3 to row 6 then paste in the second table, it should only limit to paste the row 3, not insert 3 more row.
image

HI @lumo.aq

you can control the copied data range via beforeCopy hook.

An alternative to limiting the number of total rows in the table would be to set up the maxRows option. Ref: https://handsontable.com/docs/javascript-data-grid/api/options/#maxrows

Hi thanks for reply.
I dont know which element cause the insert row, can you make a brief demo?

The example code is in the link that I added (along with the comment explanation)

Example
// To disregard a single row, remove it from array using data.splice(i, 1).
...
new Handsontable(document.getElementById('example'), {
  beforeCopy: (data, coords) => {
    // data -> [[1, 2, 3], [4, 5, 6]]
    data.splice(0, 1);
    // data -> [[4, 5, 6]]
    // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}]
  }
});
...

// To cancel copying, return false from the callback.
...
new Handsontable(document.getElementById('example'), {
  beforeCopy: (data, coords) => {
    return false;
  }
});
...
1 Like