This repository was archived by the owner on Jul 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclipboard.tsx
More file actions
57 lines (55 loc) · 3.5 KB
/
clipboard.tsx
File metadata and controls
57 lines (55 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import * as ReactDOM from 'react-dom';
import * as React from 'react';
import { GridComponent, ColumnsDirective, ColumnDirective, Page, Selection, Inject, SelectionSettings, Toolbar } from '@syncfusion/ej2-react-grids';
import { data } from './data';
import { SampleBase } from '../common/sample-base';
import './sample.css';
export class Clipboard extends SampleBase<{}, {}> {
public selectionsettings: Object = { type: 'Multiple' };
public toolbarOptions: any = [{ text: 'Copy', tooltipText: 'Copy', prefixIcon: 'e-copy', id: 'copy' }, { text: 'Copy With Header', tooltipText: 'Copy With Header', prefixIcon: 'e-copy', id: 'copyHeader' }];
private gridInstance: GridComponent;
clickHandler(args: any) {
let withHeader: boolean = false;
if (args.item.id === 'copyHeader') {
withHeader = true;
}
this.gridInstance.copy(withHeader);
}
render() {
return (
<div className='control-pane'>
<div className='control-section'>
<GridComponent dataSource={data} ref={grid => this.gridInstance = grid} enableHover={false} allowPaging={true} pageSettings={{ pageCount: 5 }} selectionSettings={this.selectionsettings} toolbar={this.toolbarOptions} toolbarClick={this.clickHandler.bind(this)}>
<ColumnsDirective>
<ColumnDirective field='OrderID' headerText='Order ID' width='120' textAlign="Right"></ColumnDirective>
<ColumnDirective field='CustomerName' headerText='Customer Name' width='150'></ColumnDirective>
<ColumnDirective field='OrderDate' headerText='Order Date' width='130' format='yMd' textAlign='Right' />
<ColumnDirective field='Freight' headerText='Freight' width='120' format='C2' textAlign='Right' />
<ColumnDirective field='ShippedDate' headerText='Shipped Date' width='130' format="yMd" textAlign="Right"></ColumnDirective>
</ColumnsDirective>
<Inject services={[Page, Selection, Toolbar]} />
</GridComponent>
</div>
<div id="action-description">
<p>This sample demonstrates copy to clipboard functionality of the Grid component. Select rows and click Copy button from
toolbar to copy content. To copy with header click Copy with header button from toolbar.
</p>
</div>
<div id="description">
<p>Selected rows or cells data in the Grid can be copied into the clipboard using the Keyboard shortcuts and <code><a target="_blank" className="code"
href="http://ej2.syncfusion.com/react/documentation/grid/api-grid.html#copy">copy
</a></code> method.
</p>
<p>In this demo, selected rows data can be copied into the clipboard using the below Keyboard shortcuts or toolbar interactions.</p>
<ul>
<li><code>Ctrl + C</code> - Selected rows or cells data without header.</li>
<li><code>Ctrl + Shift + H</code> - Selected rows or cells data with header.</li>
</ul>
<p>More information on the Clipboard feature can be found in this <a target="_blank"
href="http://ej2.syncfusion.com/react/documentation/grid/clipboard.html">documentation section</a>.
</p>
</div>
</div>
)
}
}