Handsontable / javascript - Disable adding new lines by dragging and dropping

I have a mobile table that is dynamic, that is, data can be added after initiation. However, the problem is that new rows can be added to the table when dragging by clicking on the corner of the cell. How can I prevent users from expanding the table, making sure that I can still add new rows if you could interact with the button, for example.

I tried to use

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

but this prevents me from adding new lines using the function alter. If this question was pretty vague: see the link below for jsfiddle by default using handsontable. Click on the corner of the cell and drag down, you will see.

http://jsfiddle.net/warpech/hU6Kz/

TL DR : disable row creation when dragging cells, enable row creation using (in code)handsontable.alter('insert_row');

Thanks in advance.

+4
source share
2 answers

You can add this code to prevent the creation of rows when dragging cells:

fillHandle: {
    autoInsertRow: false,
},
+3
source

EDIT . Check the fiddle .

So i added this

fillHandle: {
    autoInsertRow: false
}

and deleted minSpareRows: 1.

This gives you a drag and drop function without automatically creating rows.

To check:

(Insert row below), , .

. (, ), minSparecols: 1

, , !


fillHandle: false .

, - (contextMenu: true) (minSpareRows: 1).

+1

Source: https://habr.com/ru/post/1649870/


All Articles