copy/paste row/cell in WjFlexGrid.

Posted by: jubin.jacob on 9 December 2019, 4:56 am EST

  • Posted 9 December 2019, 4:56 am EST

    We are using angular2 extension of wijmo.
    All the cells are having object values - no primitives. Now we have to implement copy/paste of cells and rows.

    Will the default copy/paste feature, by using [autoClipboard] do any help here?
    Can you provide an example.
  • Replied 9 December 2019, 4:42 pm EST

    Hi Jubin,

    Yes, the normal copy/pasting will work even in the case in which cells are bound to objects instead of primitive values. While copying or pasting the data in the FlexGrid, it uses the actual values stored in the cells instead of the data that it is bounded to. You may refer to the sample below for a demonstration:

    Let me know if this was your requirement.

  • Replied 9 December 2019, 5:16 pm EST

    Hi Ashwin,
    Thanks for the reply.
    The example is different from what I was looking for.
    Here with binding, you are binding a primitive to cell.
    But in my case its an object assigned to cell and with use of formatters we are formatting the content and showing.
    So on copy/paste, this object should be copied to the next cell.
  • Replied 10 December 2019, 4:01 pm EST

    Hi Jubin,

    I think I understand your use case properly. But still, could you confirm whether you wish to copy/paste only the data displayed in the cell or the whole object which is bound to the cell?

  • Replied 10 December 2019, 5:41 pm EST

    Hi Ashwin,

    We want to paste the whole object in the bound cell.
  • Replied 11 December 2019, 3:11 pm EST

    Hi Pratik,

    I have created a sample for you using the copying and pasting event of the FlexGrid:

    If you will copy any cell and paste it to the same grid, the whole data bound to the cell will be pasted.

    Let me know if this works for you.

  • Replied 5 February 2020, 3:40 pm EST

    Hi Ashwin,

    Here we are using wijmo provided 'copying' and 'pasting' events and also we are using 'lostFocus' event from wijmo which clears all cell selection (, -1).

    Here the problem is when i copy the cell everything works fine but when i do pasting, 'lostFocus' event triggered before 'pasting' event which is setting 'row' and 'column' index to -1.

    Can you please help me out how can i prevent lostFocus while pasting?

  • Replied 6 February 2020, 5:39 pm EST

    Hi Kishore,

    The data is not being pasted because of how Wijmo pastes the data. When we press the paste shortcut keys, Wijmo creates an <textarea> element, moves the focus to it and paste the data. When Wijmo moves the focus to textarea, the lostFocus event of the FlexGrid is fired thereby calling the select method.
    Therefore, in the pasting event, the row and columns indexes come to be -1 and -1. To resolve this issue, simply call the select method in a setTimeout callback:
    onLostFocus(s) {
    setTimeout(() =>, -1), 100);

  • Replied 10 February 2020, 5:12 pm EST

    Hi Ashwin,

    Thanks for your response..Is there is any other way to identify the click event outside wijmo grid table (empty area).

    My requirement is upon clicking on blank area whatever cells has been selected should be unselected. Kindly let me know if there is any wijmo provided event for that.

  • Replied 11 February 2020, 2:56 pm EST


    You may handle the mousedown event on the hostElement of the FlexGrid and if use the hitTest method to check where the mouse is clicked in the FlexGrid and select the cell accordingly. Please refer to the updated sample below:

Need extra support?

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

Learn More

Forum Channels