Paste fails when the number rows/columns available are less than pasted rows/col

Originally Posted 9 September 2014, 7:24 am EST

  • Originally Posted 9 September 2014, 7:24 am EST

    When we copy and paste multiple rows/columns and the number rows available are less than copied rows the copy does not work i.e extra rows are not added automatically to paste the data. The entire paste action does not work for this scenario.

    Do you have any solution for this?
  • Reply

    The only way, I am aware of, to cancel Paste is to pass 'args=false' in ClipboardPasting event. Issue is doPaste function in wijmo checks for paste range before paste and returns from there (thus canceling the paste by itself) if available space is less to perform paste. Hence, the control doesn't reach ClipboardPasting event (which we can handle from our code).

    Also the spreadsheet you provided doesn't seem to work the way it is suppose to.
  • Reply

    Hello,

    Could you please elaborate your query further describing which control are you exactly referring to, WijGrid or SpreadJS. From where exactly are you copying the data and how are you pasting it into the Wijmo widget. Are you making use of the keyboard shortcut keys.

    Please elaborate your query further so that I can accordingly guide you ahead with this issue.

    Thanks,
    Manpreet Kaur
  • Reply

    So its similar to what we have in Microsoft excel. Below is what we are trying with spreadJS.
    If you copy 15 rows, 2 columns and try to paste it at location starting from 4th last row & second last column. The paste is not successful because wijmo checks for paste range and returns without further processing. What we expect it to do is either add additional rows/columns for paste to be successful or prompt user a message saying "Not enough space"
  • Reply

    Hello,

    The in-built copy paste functionality of SpreadJS does not provides the behaviour that you are expecting when pasting the extra rows and columns. You would need to cancel the default paste operation and manually handle the same to add the extra required rows and columns.

    Please refer to the attached HTML Page which implements the same. Hope it helps.

    Thanks,
    Manpreet Kaur
    2014/09/Spread_CopyPaste.html
  • Reply

    Hello,

    The behaviour that you are currently observing with SpreadJS is the design behaviour of SpreadJS, where in it implicitly cancels the ClipboardPasting event when the user tries to paste an invalid range of cells in SpreadJS. Hence, the ClipboardPasting event cannot be used to handle this scenario.

    As depicted in the HTML Page attached above you would need to handle the keydown event to capture, when the user presses the Ctrl+V shortcut to paste the copied contents. And manually handle the paste operation for the cells by adding the additionally required rows and columns.

    Could you please let me know what issues are you exactly facing with the custom implementation provided in the HTML Page attached above so that we can accordingly look into the issue further.

    Thanks,
    Manpreet Kaur
  • Marked as Answer

    Reply

    Hello,

    On further investigation, I could observe that you can even use the InvalidOperation event to prompt the user that there is not enough space. This event is raised, when the paste operation is unsuccessful.

    Here is the code for the same:


    activeSheet.bind($.wijmo.wijspread.Events.InvalidOperation, function (e, info) {
    alert("Message (" + info.message + ")");
    });

    Hope it helps.

    Thanks,
    Manpreet Kaur
  • Reply

    The Spread_CopyPaste.html seems not working. I guess it's because
    window.clipboardData.getData('Text')
    is not supported by browsers.
    How to get clipboard data then??
  • Reply

    Is there any way that we can remove extra rows(suppose 100 rows are allowed and we try to copy 102 rows, so remove 2 rows before paste) before pasting, so that the ClipboardPasted event will work properly?
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels