Copy to clipboard within Grid

2 posts, 0 answers
  1. Chris
    Chris avatar
    13 posts
    Member since:
    Dec 2011

    Posted 08 Sep 2017 Link to this post

    Hello,

    I'm wondering if there's an easy way to copy data from a specific row in a grid.  I have looked up examples however they have all dealt with copying the entire grid rather than data within specific rows.  A simple example would be a grid with two columns, the first contains the data to be copied within a standard GridBoundColumn and the second is a button (GridButtonColumn) to copy data from the row.  If I click the copy button for a given row it would copy the data contents (from the GridBoundColumn) for that given row and put it on the clipboard.  Is this possible?

    Thanks

  2. Eyup
    Admin
    Eyup avatar
    3824 posts

    Posted 12 Sep 2017 Link to this post

    Hi Chris,

    You can achieve this requirement using the following steps:

    1. Pass the ItemIndex of the grid row to client-side:
    http://www.telerik.com/forums/passing-arguments-to-client-events#QkAxV87iOUalEx4wNaumeA

    2. Access the item using the get_dataItems[index] method:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#getcellbycolumnuniquename

    3. Extract the text of the cell:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#get_cell

    4. Set the text content to the clipboard. This last step is not related to Telerik specifically and you can check various sources over the net on this matter:
    https://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript
    https://stackoverflow.com/questions/22581345/click-button-copy-to-clipboard-using-jquery

    I hope this will prove helpful.

    Regards,
    Eyup
    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