|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: Events in React Spreadsheet component | Syncfusion |
| 4 | +description: Learn here all about the events in Syncfusion React Spreadsheet component of Syncfusion Essential JS 2 and more. |
| 5 | +control: Events |
| 6 | +platform: document-processing |
| 7 | +documentation: ug |
| 8 | +--- |
| 9 | + |
| 10 | +# Events in React Spreadsheet Component |
| 11 | + |
| 12 | +The Spreadsheet component triggers events for creation, data binding, selection, editing, clipboard actions, sorting, filtering, formatting, row and column insertion or deletion, context menu and ribbon interactions, and import/export operations—enabling integration of custom logic into application workflows. |
| 13 | + |
| 14 | +## Action Events |
| 15 | + |
| 16 | +The `actionBegin` and `actionComplete` events are the primary action events in the Spreadsheet. |
| 17 | + |
| 18 | +The `actionBegin` event triggers when any action begins in the Spreadsheet and fires for all user-initiated actions, enabling you to identify the action type, prevent specific actions from executing, and apply custom logic at the initiation of an action. |
| 19 | + |
| 20 | +The `actionComplete` event triggers when any action completes in the Spreadsheet and fires for all user-initiated actions, enabling you to identify the action type and apply custom logic after an action has successfully completed. |
| 21 | + |
| 22 | +You can identify the type of action being triggered by using the `args.action` property during both the action events. |
| 23 | + |
| 24 | +The following table represents the action names for which the `actionBegin` and `actionComplete` events are triggered in the Spreadsheet: |
| 25 | + |
| 26 | +| **Action** | **ActionBegin** | **ActionComplete** | |
| 27 | +|--------|-------------|----------------| |
| 28 | +| Add Data Validation | validation | validation | |
| 29 | +| Add Defined Name | - | addDefinedName | |
| 30 | +| Autofill | autofill | autofill | |
| 31 | +| Autofit | resizeToFit | resizeToFit | |
| 32 | +| Cell Delete | cellDelete | cellDelete | |
| 33 | +| Cell Save (Edit) | cellSave | cellSave | |
| 34 | +| Chart Design | chartDesign | chartDesign | |
| 35 | +| Chart Deletion | deleteChart | deleteChart | |
| 36 | +| Chart Insertion | beforeInsertChart | insertChart | |
| 37 | +| Chart (Resize/Drag and Drop) | - | chartRefresh | |
| 38 | +| Clear | beforeClear | clear | |
| 39 | +| Clear Conditional Formatting | - | clearCF | |
| 40 | +| Clear Validation | removeValidation | removeValidation | |
| 41 | +| Clear Highlight | removeHighlight | removeHighlight | |
| 42 | +| Clipboard (Copy) | copy | - | |
| 43 | +| Clipboard (Cut) | cut | - | |
| 44 | +| Clipboard (Paste) | clipboard | clipboard | |
| 45 | +| Comment | addComment | addComment | |
| 46 | +| Conditional Formatting | conditionalFormat | conditionalFormat | |
| 47 | +| Delete | delete | delete | |
| 48 | +| Delete Comment | deleteComment | deleteComment | |
| 49 | +| Delete (Rows/Columns) | delete | delete | |
| 50 | +| Filter | filter | filter | |
| 51 | +| Formatting (Cell/Number) | format | format | |
| 52 | +| Freeze Panes | freezePanes | freezePanes | |
| 53 | +| Gridlines | gridlines | gridlines | |
| 54 | +| Headers | headers | headers | |
| 55 | +| Hide (Row/Column) | hideShow | hideShow | |
| 56 | +| Highlight Invalid Data | addHighlight | addHighlight | |
| 57 | +| Hyperlink | hyperlink | hyperlink | |
| 58 | +| Image Deletion | deleteImage | deleteImage | |
| 59 | +| Image Insertion | beforeInsertImage | insertImage | |
| 60 | +| Image (Resize/Drag and Drop) | - | imageRefresh | |
| 61 | +| Insert (Row/Column/Sheet) | insert | insert | |
| 62 | +| Merge | merge | merge | |
| 63 | +| Open | beforeOpen | import | |
| 64 | +| Protect Sheet | protectSheet | protectSheet | |
| 65 | +| Read-Only | readonly | readonly | |
| 66 | +| Remove Defined Name | - | removeDefinedName | |
| 67 | +| Replace | beforeReplace | replace | |
| 68 | +| Replace All | beforeReplaceAll | replaceAll | |
| 69 | +| Resize (Row/Column) | - | resize | |
| 70 | +| Save | beforeSave | - | |
| 71 | +| Sort | beforeSort | sorting | |
| 72 | +| Sheet Duplicate | duplicateSheet | duplicateSheet | |
| 73 | +| Sheet Hide | hideSheet | hideSheet | |
| 74 | +| Sheet Move | moveSheet | moveSheet | |
| 75 | +| Sheet Rename | renameSheet | renameSheet | |
| 76 | +| Wrap | beforeWrap | wrap | |
| 77 | + |
| 78 | + |
| 79 | +The following code example demonstrates how to bind the `actionBegin` and `actionComplete` events in the Spreadsheet. |
| 80 | + |
| 81 | +{% tabs %} |
| 82 | +{% highlight js tabtitle="app.jsx" %} |
| 83 | +{% include code-snippet/spreadsheet/react/events/app/app.jsx %} |
| 84 | +{% endhighlight %} |
| 85 | +{% highlight ts tabtitle="app.tsx" %} |
| 86 | +{% include code-snippet/spreadsheet/react/events/app/app.tsx %} |
| 87 | +{% endhighlight %} |
| 88 | +{% endtabs %} |
| 89 | + |
| 90 | +{% previewsample "/document-processing/code-snippet/spreadsheet/react/events" %} |
| 91 | + |
| 92 | +## Clipboard |
| 93 | + |
| 94 | +When performing clipboard operations such as **Cut**, **Copy**, or **Paste**, the Spreadsheet triggers specific events that allow you to monitor and manage these actions effectively. The following sections outline the event sequence and their roles. |
| 95 | + |
| 96 | +### Cut / Copy |
| 97 | + |
| 98 | +For **Cut** or **Copy** actions, only the [`actionBegin`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#actionbegin) event is triggered. You can identify the action type and access the copied range by using the following properties: |
| 99 | + |
| 100 | +* `args.action === 'cut'` → Indicates a Cut action |
| 101 | +* `args.action === 'copy'` → Indicates a Copy action |
| 102 | +* `args.args.copiedRange` → Provides the range of copied cells |
| 103 | + |
| 104 | +### Paste |
| 105 | + |
| 106 | +During a **Paste** operation, events are triggered in the following sequence: |
| 107 | + |
| 108 | +> actionBegin → beforeCellUpdate → cellSave → actionComplete |
| 109 | +
|
| 110 | +The table below describes each event and its role in the paste process: |
| 111 | + |
| 112 | +| **Event** | **Description** | **Event Arguments** | |
| 113 | +|-----------|------------------|----------------------| |
| 114 | +| [`actionBegin`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#actionbegin) | Triggers when the paste action starts. | [`ActionBeginEventArgs`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#actionbegin) | |
| 115 | +| [`beforeCellUpdate`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#beforecellupdate) | Triggers for each cell in the pasted range before it is updated, allowing you to modify cell properties or cancel the `paste` action. | [`BeforeCellUpdateArgs`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/beforecellupdateargs) | |
| 116 | +| [`cellSave`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#cellsave) | Triggers for each cell in the pasted range after the modified cell is saved. | [`CellSaveEventArgs`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/cellsaveeventargs) | |
| 117 | +| [`actionComplete`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#actioncomplete) | Triggers after all pasted cells are fully saved. | [`ActionCompleteEventArgs`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#actioncomplete) | |
| 118 | + |
| 119 | +### Accessing copied and pasted ranges |
| 120 | + |
| 121 | +You can access the copied and pasted ranges during paste operations by using the [`actionBegin`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#actionbegin) and [`actionComplete`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#actioncomplete) events. Verify the action type using: |
| 122 | + |
| 123 | +* `args.action === 'clipboard'` → Indicates a paste action |
| 124 | + |
| 125 | +Once verified, you can access the following properties: |
| 126 | + |
| 127 | +* `args.eventArgs.copiedRange` → The range of cells that were copied |
| 128 | +* `args.eventArgs.pastedRange` → The range of cells where content was pasted |
| 129 | + |
| 130 | +## Editing |
| 131 | + |
| 132 | +When a cell is edited manually—such as by **double-clicking the cell**, **pressing the F2 key**, or **modifying it through the formula bar**—the Spreadsheet triggers a series of events. These events allow you to monitor and manage the entire editing process, from initiation to completion. |
| 133 | + |
| 134 | +The sequence of events during manual cell editing is: |
| 135 | + |
| 136 | +> cellEdit → cellEditing → actionBegin → beforeCellUpdate → beforeCellSave → cellSave → cellEdited → actionComplete |
| 137 | +
|
| 138 | +The table below describes each event and its role in the editing process: |
| 139 | + |
| 140 | +| **Event** | **Description** | **Event Arguments** | |
| 141 | +|-----------|------------------|----------------------| |
| 142 | +| [`cellEdit`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#celledit) | Triggers before the cell enters edit mode. | [`CellEditEventArgs`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/cellediteventargs) | |
| 143 | +| [`cellEditing`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#cellediting) | Triggers while editing is in progress; fires for each change made to the cell content. | [`CellEditingEventArgs`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/cellediteventargs) | |
| 144 | +| [`actionBegin`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#actionbegin) | Triggers when the edit action starts. | [`ActionBeginEventArgs`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#actionbegin) | |
| 145 | +| [`beforeCellUpdate`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#beforecellupdate) | Triggers before any cell property (style, value, formula, etc.) is modified. | [`BeforeCellUpdateArgs`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/beforecellupdateargs) | |
| 146 | +| [`beforeCellSave`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#beforecellsave) | Triggers before the cell value is saved. | [`BeforeCellSaveEventArgs`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/cellediteventargs) | |
| 147 | +| [`cellSave`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#cellsave) | Triggers when the modified cell value is saved. | [`CellSaveEventArgs`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/cellsaveeventargs) | |
| 148 | +| [`cellEdited`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#celledited) | Triggers after the editing process completes. | [`CellEditedEventArgs`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/cellediteventargs) | |
| 149 | +| [`actionComplete`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#actioncomplete) | Triggers once the entire edit operation is completed. | [`ActionCompleteEventArgs`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#actioncomplete) | |
| 150 | + |
| 151 | +## See Also |
| 152 | + |
| 153 | +* [Editing](./editing.md) |
| 154 | +* [Clipboard](./clipboard.md) |
0 commit comments