Copy paste - clipboard

how can i handle this error, in a Datatable i will copy 5 cell data and try to paste in 6cells or 4 cells, they can be random and contiguous. For now i’m using onPaste event and template copying, but i am not understanding the issue of error handling in this type of operation

If default logic of paste doesn’t work for you. You can set clipboard property as clipboard:"custom" and use onPaste event

in the event handler you can get infor about source data and about selectin in the grid

dtable.attachEvent("onPaste", function(text) {}); i will just get the copied data that i have copied. How can i get the “Copied from data(origin of copy)” and

(1) number of copied data
(2) from which cells i have copied
(3) how many cells i should select to paste the data

The values are getting pasted in cell even before the event for onPaste is called … i am making use of ctrl+c and ctrl+p hotkeys to get the ID of the copied and pasted cells, can i check if the # of copied cells = # of to selected cells to be pasted and perform Op. based on their result

(2) you can’t get such info. Copy paste operation can be done from outside of browser window. There is no guarantee that data was copied from some other datatable.

(1)(3) you can use var data = webix.csv.parse(text, this.config.delimiter); to get the data as matrix of values

As for onPaste events, yep it can’t be used to block default pasting. But in pair with clipboard:"custon" it does allow to define a custom pasting reaction ( as there is no default one, on moment of onPaste event nothing will be pasted yet )

sorry i could not understand, (1). default pasting cant be blocked at all ?

During inspection of code, as the control enters into onPaste event i can see the cells getting updated. onPaste is the event which i am using to detect the cells numbers and trying to display an error/warning if #of cells is different, if the data i already pasted by the time i notify the user how can the original data be fetched back(as the data is already been updated in datatable)

You can allow default pasting logic or fully block default pasting logic.

There is no way to do it conditionally. You can’t place some code in onPaste event and block or allow the pasting from there.

You can block default pasting and you onPaste event for your custom pasting logic ( your code will decide is pasting allowed or not and will put values from clipboard to necessary cells )