This is a migrated thread and some comments may be shown as answers.

Copy to clipboard within Grid

1 Answer 662 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 08 Sep 2017, 06:18 AM

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

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 12 Sep 2017, 11:42 AM
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.
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or