Copy & Paste (clipboard)
DataGridXL comes with clipboard support. Admittedly, that has not been the easiest feature to include, but in general we think it turned out very well.
Copy & Cut
Copy & Cut actions are supported on any device, on any supported browser. Your users can copy and cut using shortcut key commands (Ctrl+C, Ctrl+X) and from DataGridXL's built-in context menus (in both desktop and touch menus).
You can also trigger these actions by code using grid.copy() or grid.cut(), as long as the grid has at least a single cell selected.
The selected cell values are sent to the clipboard in a TSV-string (Tab Seperated Values). This assures compatibility with spreadsheet applications like Excel and Google Spreadsheets.
Cut, instant or delayed?
By default, the cut action in DataGridXL will draw a dashed-border range, but it won't instantly clear the cell values. The "cut range" will only be emptied when the cut action is followed by a paste action (in the same grid). This is similar to how Google Sheets implements their cut action.
If you wish to clear values instantly, pass delayedCut: false to your grid options. A useful option if you have multiple grids on a single web page. (Pasting your cut values into grid B will not clear the original cut range in grid A.)
Paste
Unfortunately, paste is a little more complex. All browsers allow paste when it comes explicitely from the user (via CTRL+V or via the browser application's toolbar).
Triggering a paste by code (grid.paste()) or from DataGridXL context menu does not work in all browsers, because of browser security measures that we cannot work around.
In the following browsers, grid.paste() will work:
- Any browser that supports the Async Clipboard API (including Edge, Chrome & Android Chrome). Make sure that your page is served over https.
- Internet Explorer (we're not kidding!)
Because of this limited "paste by code support", we've chosen not to include the paste option in DataGridXL's default context menu. However, if you know that your users are on the latest & greatest, you can choose to include "paste" in your contextMenuItems array.
Paste on mobile devices
We haven't found a way to enable manual paste on iOS devices. That's why there is no option in the default set of ContextMenuTouchItems.
We did find a way to implement manual paste on Android devices, but we didn't want to create a different experience on iOS vs Android. For now we've decided to not support pasting on touch devices.
If we find a way to make paste work on iOS, we'll likely introduce the paste option in the Context Menu (touch).