Copying Row Data from the Grid by Using the Angular Material Clipboard Service
Environment
| Product | Progress® Kendo UI® Data Grid for Angular | 
Description
How can I copy row data from the Kendo UI for Angular Grid component by using the Angular Material Clipboard service?
Solution
The Kendo UI for Angular Data Grid does not provide a built-in way to copy row data to the clipboard. However, you can use the Angular Material Clipboard service to implement this functionality.
The following solution is only a basic example of how to copy row data from the Grid component. You can customize the implementation to suit your needs.
- 
Install the @angular/cdkpackage:shnpm install @angular/cdk
- 
Import the ClipboardModulein the module where you want to use the Clipboard service:tsimport { ClipboardModule } from '@angular/cdk/clipboard'; @NgModule({ ... imports: [ ... ClipboardModule ], ... })
- 
Inject the Clipboardservice in the component where you want to use it:tsimport { Clipboard } from '@angular/cdk/clipboard'; export class AppComponent { constructor(private clipboard: Clipboard) { } }
- 
Use the cellClickevent of the Grid to get the row data and save it in a variable:html<kendo-grid [data]="gridData" [selectable]="selectableSettings" (cellClick)="onCellClick($event)" > </kendo-grid>tsexport class AppComponent { public rowData: string = ''; public selectableSettings: SelectableSettings = { mode: 'single' }; public onCellClick(event: CellClickEvent): void { this.rowData = JSON.stringify(event.dataItem); } }
- 
Add a button to the toolbar template of the Grid and bind its clickevent to the customonCopyDatamethod:html<kendo-grid> <ng-template kendoGridToolbarTemplate> <button kendoButton (click)="onCopyData()">Copy Row Data</button> </ng-template> </kendo-grid>
- 
Use the copymethod of the Clipboard service to copy the row data to the clipboard:tspublic onCopyData(): void { this.clipboard.copy(this.rowData); }