Select and paste
Step 6 of 8
Select ranges of cells with the pointer and the keyboard, then copy them out or paste spreadsheet data in.
Before you start, keep edits in state. This step needs no code. The grid you have already supports it.
Select cells
A range is a rectangle of selected cells. Try these gestures on the grid:
- Press a cell and drag. The grid paints a range from that cell to the pointer.
- Shift+click extends the range from the anchor cell, the cell where the selection started.
- Ctrl/Cmd+click adds a second range.
- Shift+an arrow key extends the range from the active cell, the cell that has focus.
- A click on a column header selects the whole column.
Copy and cut
Ctrl/Cmd+C copies the last range you selected. The clipboard gets tab-separated text and an HTML table, so a spreadsheet app reads the cells. Ctrl/Cmd+X copies the same way and then clears the cells. On a grid with readOnly, cut only copies.
While a cell editor is open, the editor handles copy, cut, and paste.
Paste
Select one cell, then press Ctrl/Cmd+V. The pasted block lands with its top-left corner on the top-left cell of the selection. It stops at the last row and the last column of the grid. A paste adds no rows.
- One pasted row repeats down a taller selection.
- A read-only cell keeps its value.
- A paste calls
onDataChangeonce, with the source"paste".
- Select the Name cells of Grace Hopper and Margaret Hamilton.
- Press Ctrl/Cmd+C.
- Select the Name cell of Ada Lovelace.
- Press Ctrl/Cmd+V.
Result: the first two rows show the copied names. The grid writes both in one change.
Next: Sort and filter rows.