Range Copy Paste

10 posts, 1 answers
  1. Marc
    Marc avatar
    161 posts
    Member since:
    Sep 2016

    Posted 11 Aug Link to this post

    Hi,

    Is there anyway to overwrite the default value of the copy / paste functionality so that when a user copies a range and pastes it, the copy range formatting is not copied? (ie, copy value only)

    Or is there some event I can intercept and use to do this?

    Thanks

    Marc

  2. Answer
    Ivan Danchev
    Admin
    Ivan Danchev avatar
    1268 posts

    Posted 15 Aug Link to this post

    Hi Marc,

    Currently there is no configuration option that allows to enable/disable pasting cells with/without formatting. We are considering the implementation of such in a future release. A possible workaround exists and consists of overwriting the paste function of the prototype as shown in this dojo example. 

    Regards,
    Ivan Danchev
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Marc
    Marc avatar
    161 posts
    Member since:
    Sep 2016

    Posted 15 Aug in reply to Ivan Danchev Link to this post

    Hi Ivan!

    This is great, thanks so much!

  4. Marc
    Marc avatar
    161 posts
    Member since:
    Sep 2016

    Posted 26 Aug Link to this post

    Hi Ivan

    In the example dojo, the formatting is copied. Can you update it so that the formatting it not copied and only the data is copied over?

    Thanks!

  5. Ivan Danchev
    Admin
    Ivan Danchev avatar
    1268 posts

    Posted 29 Aug Link to this post

    Hi Marc,

    We do not have a different workaround for that missing feature, but the one I linked works as expected at my end. Here's a short screencast showing only the data being pasted, while formatting  (the cells background color for instance) not being pasted.

    Regards,
    Ivan Danchev
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  6. Marc
    Marc avatar
    161 posts
    Member since:
    Sep 2016

    Posted 29 Aug in reply to Ivan Danchev Link to this post

    Hi Ivan,

    It works in your example yes, but if you copy that onto a cell that is already formatted then it will remove the formatting that is currently there.

    This is the behaviour I'm looking for - ie, a ctrl+c - ctrl+v only copies the cell value.

    Thanks!

  7. Ivan Danchev
    Admin
    Ivan Danchev avatar
    1268 posts

    Posted 31 Aug Link to this post

    Hi Marc,

    Currently there isn't a reliable approach available that would prevent the formatting removal in the pasted cell. It could be done manually by setting the previous format to the cell after the content is pasted, but that would require calling multiple methods of the Range object for setting different formatting options (bold, textAlign, background, color, etc.). Here's an example which shows this with just two of the methods (background and textAlign):
    var background = sheet.range(pasteRef).background();
    var textAlign = sheet.range(pasteRef).textAlign();

    sheet.range(pasteRef).background(background)
    sheet.range(pasteRef).textAlign(textAlign);

    Copy a cell's content from a column and paste it in a cell in another column: the original background and text alignment are persisted in the pasted cell.


    Regards,
    Ivan Danchev
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  8. Marc
    Marc avatar
    161 posts
    Member since:
    Sep 2016

    Posted 31 Aug in reply to Ivan Danchev Link to this post

    Hi Ivan,

    This is great thanks!

    Just an FYI - you can chain the calls like so (to avoid multiple references to the range):

    sheet.range(pasteRef)

         .background(background)
         .textAlign(textAlign);

  9. Ivan Danchev
    Admin
    Ivan Danchev avatar
    1268 posts

    Posted 04 Sep Link to this post

    Hi Marc,

    We are glad the suggested approach worked out. We are aware of the methods chaining option, which would be reasonable to use, especially if there are calls to multiple methods.

    Regards,
    Ivan Danchev
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  10. Marc
    Marc avatar
    161 posts
    Member since:
    Sep 2016

    Posted 04 Sep in reply to Ivan Danchev Link to this post

    Hi Ivan,

    Thanks again - impressed as always with the support I get here1

    Marc

     

Back to Top