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

Copy to clipboard the grid

4 Answers 478 Views
Grid
This is a migrated thread and some comments may be shown as answers.
serge
Top achievements
Rank 2
Bronze
Iron
Iron
serge asked on 21 Apr 2021, 08:02 AM

Our customers like to take data from the grid, and put it in editors like notepad, excel, word or others... 

 

Is there a way to copy the visible, or, all, the grid data to clipboard, as tab separated values? as in the attached picture

 

 

4 Answers, 1 is accepted

Sort by
-2
serge
Top achievements
Rank 2
Bronze
Iron
Iron
answered on 21 Apr 2021, 01:02 PM
Actually "solved" by using the "Export to excel" functionality, but that is not exacly that to copy the data to clipboard...
0
Nikolay
Telerik team
answered on 26 Apr 2021, 05:59 AM

Hi Serge,

The recommended way of exporting Grid data to Excel is by using the internal Excel export functionality.

Nevertheless, you can also select all Grid data and copy it to the clipboard with some custom logic. For example:

$(document).ready(function () {
        $("#selectAll").click(function () {
          var grid = $("#grid").data("kendoGrid")
          grid.select(grid.tbody.find(">tr td"));
          grid.copySelection(grid);
          document.execCommand("copy");
        });

Here is a small Dojo demo I prepared demonstrating this:

The logic for selecting and copying the data is also valid for Html Helper Grid.

Let me know if yo have any questions.

Regards,
Nikolay
Progress Telerik

Тhe web is about to get a bit better! 

The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.

serge
Top achievements
Rank 2
Bronze
Iron
Iron
commented on 27 Apr 2021, 06:06 PM

by the way, your Grid has this fonctionnality, to copy a selected range of data to clipboard (Excel ready) https://demos.telerik.com/aspnet-core/grid/copy-to-excel
0
serge
Top achievements
Rank 2
Bronze
Iron
Iron
answered on 26 Apr 2021, 06:49 AM

Hello, Nikolay

I tested your example, it does a mix between copying the visible data and available data.... I mean, it copies more than visible, but less than all data...

1
Accepted
Nikolay
Telerik team
answered on 28 Apr 2021, 09:59 PM

Hi Serge,

This can be achieved by enabling the Grid property AllowCopy which will allow the user could copy the selection into the clipboard and paste it into Excel or other similar programs that understand TSV/CSV formats.

Here is a working example you can test:

Regards,
Nikolay
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
serge
Top achievements
Rank 2
Bronze
Iron
Iron
Answers by
serge
Top achievements
Rank 2
Bronze
Iron
Iron
Nikolay
Telerik team
Share this question
or