How to differentiate between pasted data (Copied from other spreadsheet) and manually written data in kendo spreadsheet.

4 posts, 0 answers
  1. Partha Pratim
    Partha Pratim avatar
    3 posts
    Member since:
    Jan 2016

    Posted 08 Jun 2017 Link to this post

    We need to do some format change operation only for pasted data which is copied from other spreadsheet. That format change is not applicable for manually written data  We have tried to distinguish pasted data from manually written data in 'Change' event of spreadsheet but could not find any clue.
  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    2084 posts

    Posted 08 Jun 2017 Link to this post

    Hello,

    There isn't a built-in method that allows to differentiate pasted from typed data. You could use jQuery to detect pasting in the Spreadsheet, then get the selected range and format it. See this dojo for 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. Partha Pratim
    Partha Pratim avatar
    3 posts
    Member since:
    Jan 2016

    Posted 15 Jun 2017 in reply to Ivan Danchev Link to this post

    Thanks Ivan for your reply. But I think there is a problem with selection() method of sheet. It actually returns single row and single column though there are multiple selected rows and columns present. That's why only first cell is getting updated instead of every rows and columns. Please refer to the screenshot of the dojo. 
  4. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    1207 posts

    Posted 16 Jun 2017 Link to this post

    Hi,

    You are correct, that the selection() method in this scenario would return only the top-left pasted cell. In order to cover the case with pasting multiple cells, I would suggest you to implement a handler for the change event:
    change: function(e) {
      setTimeout(function() {
        if (isPasted) {
          isPasted = false;
           
          var changedRange = e.range;
          changedRange.background("lightgreen");
        }
      }, 0);
    },

    and alter the paste handler implementation to:
    $('.k-spreadsheet').on('paste', function () {
      isPasted = true
    });

    Here you will find a modified version of the Dojo, which implements the above suggestion.

    Regards,
    Veselin Tsvetanov
    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.
Back to Top