beforeCreateRow on paste multi row

Tags: #<Tag:0x00007efc651b0158>

Hi, I want only allow to create new row if the last row is not empty.
So I using beforeCreateRow and isEmptyRow to check the last row is empty or not.
But when I paste multi row, it’s only paste the first row. How can I do that ?
http://jsfiddle.net/TonyNguyen001/9omcp5jL/6/

Thanks in advance !

Hi @khanguyen96

Can you tell how do you want to add new rows? Should the users be able to do that? Or maybe do you want to assign a button to that function?

Let us know about that part and we will be able to investigate the issue further.

I want alway have a spare row at the end. The new row will added automatically when user input at spare row (If user input blank, the new row will not be added)
And I want it’s work when user copy multi row and paste them at the end

Hey @khanguyen96

this is how the minSpareRows works now.

25

you copy some area of cells and when you copy you get all of the pasted data + one empty row

35

Do you have any other data structure?

Hi @aleksandra_budnik
If using only minSpareRows = 1, I can create many empty row like below image by using enter keyboard
image
I just want create row if the last row is not empty

A new row only create when I input with value at the end
image

Hi @khanguyen96

There are some workarounds that you can try but we can’t guarantee that it will work flawlessly.

First way. In beforeChange hook you can cancel the changes if the arguments are empty string.
Second possible solution is to use beforeKeyDown and check cell content there.

Hi @adrian.szymanski, thanks for replying
I tried beforeChange but it doesn’t work.
If I use beforeCreateRow, it’s work when I input. But when I do paste multi row, it’s only paste the first row into table. Is there any way could I handle in beforeCreateRow
http://jsfiddle.net/TonyNguyen001/9omcp5jL/6/

Hi @khanguyen96

If you need a custom demo please send me your license ID at support@handsontable.com so we can check your support plan. If you don’t have a support plan we can offer consulting service.

1 Like