-
Notifications
You must be signed in to change notification settings - Fork 11
documentation(EJ2-996127): Add a UG Section on Events Triggered During Editing and Clipboard Actions in Spreadsheet #2120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DinakarManickam4212
wants to merge
1
commit into
development
Choose a base branch
from
EJ2-996127-react-dev
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+625
−10
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ documentation: ug | |
|
|
||
| # Clipboard in React Spreadsheet component | ||
|
|
||
| The Spreadsheet provides support for the clipboard operations (cut, copy, and paste). Clipboard operations can be enabled or disabled by setting the [`enableClipboard`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/#enableclipboard) property in Spreadsheet. | ||
| The Spreadsheet provides support for the clipboard operations (cut, copy, and paste). Clipboard operations can be enabled or disabled by setting the [`enableClipboard`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet#enableclipboard) property in Spreadsheet. | ||
|
|
||
| > By default, the `enableClipboard` property is true. | ||
|
|
||
|
|
@@ -24,7 +24,7 @@ Cut can be done in one of the following ways. | |
| * Using Cut button in the Ribbon’s HOME tab to perform cut operation. | ||
| * Using Cut option in the Context Menu. | ||
| * Using `Ctrl + X` | `Command + X` keyboard shortcut. | ||
| * Using the [`cut`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/#cut) method. | ||
| * Using the [`cut`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet#cut) method. | ||
|
|
||
| ## Copy | ||
|
|
||
|
|
@@ -37,7 +37,7 @@ Copy can be done in one of the following ways. | |
| * Using Copy button in the Ribbon’s HOME tab to perform copy operation. | ||
| * Using Copy option in the Context Menu. | ||
| * Using `Ctrl + C` | `Command + C` keyboard shortcut. | ||
| * Using the [`copy`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/#copy) method. | ||
| * Using the [`copy`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet#copy) method. | ||
|
|
||
| ## Paste | ||
|
|
||
|
|
@@ -55,7 +55,7 @@ Paste can be done in one of the following ways. | |
| * Using Paste button in the Ribbon’s HOME tab to perform paste operation. | ||
| * Using Paste option in the Context Menu. | ||
| * Using `Ctrl + V` | `Command + V` keyboard shortcut. | ||
| * Using the [`paste`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/#paste) method. | ||
| * Using the [`paste`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet#paste) method. | ||
|
|
||
| > If you use the Keyboard shortcut key for cut (`Ctrl + X`) / copy (`Ctrl + C`) from other sources, you should use `Ctrl + V` shortcut while pasting into the spreadsheet. | ||
|
|
||
|
|
@@ -78,7 +78,7 @@ Paste can be done in one of the following ways. | |
|
|
||
| ## Prevent the paste functionality | ||
|
|
||
| The following example shows, how to prevent the paste action in spreadsheet. In [`actionBegin`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/#actionbegin) event, you can set `cancel` argument as false in paste request type. | ||
| The following example shows, how to prevent the paste action in spreadsheet. In [`actionBegin`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet#actionbegin) event, you can set `cancel` argument as false in paste request type. | ||
|
|
||
| {% tabs %} | ||
| {% highlight js tabtitle="app.jsx" %} | ||
|
|
@@ -97,6 +97,66 @@ The following example shows, how to prevent the paste action in spreadsheet. In | |
|
|
||
| {% previewsample "/document-processing/code-snippet/spreadsheet/react/clipboard-cs2" %} | ||
|
|
||
| ## Events triggered during clipboard operations | ||
|
|
||
| When performing clipboard operations such as **Cut**, **Copy**, or **Paste**, the spreadsheet triggers specific events that allow users to monitor and manage these actions effectively. The following sections outline the event sequence and their roles. | ||
|
|
||
| **Cut / Copy** | ||
|
|
||
| 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 type of action and access the copied range using the following properties: | ||
|
|
||
| * `args.action === 'cut'` → Indicates a Cut action | ||
| * `args.action === 'copy'` → Indicates a Copy action | ||
| * `args.args.copiedRange` → Provides the copied range | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Provides the copy or cut range |
||
|
|
||
| **Paste** | ||
|
|
||
| During a **Paste** operation, events are triggered in the following sequence: | ||
|
|
||
| > actionBegin → beforeCellUpdate → cellSave → actionComplete | ||
|
|
||
| The table below describes each event and its role in the paste process: | ||
|
|
||
| | Event | Description | | ||
| |-------------------|---------------------------------------------------------------------------------------------| | ||
| | [`actionBegin`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#actionbegin) | Triggers when the paste action starts. | | ||
| | [`beforeCellUpdate`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#beforecellupdate) | Triggers for each cell in the pasted range before its properties are updated. | | ||
| | [`cellSave`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#cellsave) | Triggers for each cell in the pasted range after the updated cell is saved. | | ||
| | [`actionComplete`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#actioncomplete) | Triggers once all pasted cells are processed. | | ||
|
|
||
| The following code example showcases the events triggered during clipboard operations in spreadsheet. | ||
|
|
||
| {% tabs %} | ||
| {% highlight js tabtitle="app.jsx" %} | ||
| {% include code-snippet/spreadsheet/react/clipboard-cs3/app/app.jsx %} | ||
| {% endhighlight %} | ||
| {% highlight ts tabtitle="app.tsx" %} | ||
| {% include code-snippet/spreadsheet/react/clipboard-cs3/app/app.tsx %} | ||
| {% endhighlight %} | ||
| {% highlight js tabtitle="datasource.jsx" %} | ||
| {% include code-snippet/spreadsheet/react/clipboard-cs3/app/datasource.jsx %} | ||
| {% endhighlight %} | ||
| {% highlight ts tabtitle="datasource.tsx" %} | ||
| {% include code-snippet/spreadsheet/react/clipboard-cs3/app/datasource.tsx %} | ||
| {% endhighlight %} | ||
| {% endtabs %} | ||
|
|
||
| {% previewsample "/document-processing/code-snippet/spreadsheet/react/clipboard-cs3" %} | ||
|
|
||
| > **Note**: The events [cellEdit](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#celledit), [cellEditing](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#cellediting), and [beforeCellSave](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#beforecellsave) are not triggered during clipboard operations. These events are specific to manual cell edits. However, [beforeCellUpdate](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#beforecellupdate) is triggered for each cell update before any property is changed, including during paste actions. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this |
||
|
|
||
| **Accessing clipboard properties** | ||
|
|
||
| You can access clipboard-related properties such as the copied and pasted ranges during paste operations 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. Ensure the action and request type using: | ||
|
|
||
| * `args.action === 'clipboard'` | ||
| * `args.eventArgs.requestType === 'paste'` | ||
|
|
||
| Once confirmed, you can access the following properties: | ||
|
|
||
| * `args.eventArgs.copiedRange` | ||
| * `args.eventArgs.pastedRange` | ||
|
|
||
| ## Limitations | ||
|
|
||
| * External clipboard is not fully supported while copying data from another source and pasting into a spreadsheet, it only works with basic supports (Values, Number, cell, and Text formatting). | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
Document-Processing/code-snippet/spreadsheet/react/clipboard-cs3/app/app.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import * as React from 'react'; | ||
| import { createRoot } from 'react-dom/client'; | ||
| import { SpreadsheetComponent, SheetsDirective, SheetDirective, RangesDirective } from '@syncfusion/ej2-react-spreadsheet'; | ||
| import { RangeDirective, ColumnsDirective, ColumnDirective } from '@syncfusion/ej2-react-spreadsheet'; | ||
| import { data } from './datasource'; | ||
|
|
||
| function App() { | ||
| let spreadsheet; | ||
| const spreadsheetRef = React.useRef(null); | ||
|
|
||
| const onCreated = () => { | ||
| spreadsheet = spreadsheetRef.current; | ||
| spreadsheet.cellFormat({ backgroundColor: '#357cd2', color: '#fff', fontWeight: 'bold', textAlign: 'center' }, 'A1:H1'); | ||
| } | ||
|
|
||
| const actionBegin = (args) => { | ||
| console.log('actionBegin triggered'); | ||
| } | ||
|
|
||
| const beforeCellSave = (args) => { | ||
| console.log('beforeCellSave triggered') | ||
| } | ||
|
|
||
| const beforeCellUpdate = (args) => { | ||
| console.log('beforeCellUpdate triggered'); | ||
| } | ||
|
|
||
| const cellEdit = (args) => { | ||
| console.log('cellEdit triggered'); | ||
| } | ||
|
|
||
| const cellEditing = (args) => { | ||
| console.log('cellEditing triggered') | ||
| } | ||
|
|
||
| const cellEdited = (args) => { | ||
| console.log('cellEdited triggered'); | ||
| } | ||
|
|
||
| const cellSave = (args) => { | ||
| console.log('cellSave triggered') | ||
| } | ||
|
|
||
| const actionComplete = (args) => { | ||
| console.log('actionComplete triggered'); | ||
| } | ||
|
|
||
| return ( | ||
| <div> | ||
| <SpreadsheetComponent ref={spreadsheetRef} created={onCreated} actionBegin={actionBegin} beforeCellSave={beforeCellSave} beforeCellUpdate={beforeCellUpdate} cellSave={cellSave} cellEdit={cellEdit} cellEditing={cellEditing} cellEdited={cellEdited} actionComplete={actionComplete} > | ||
| <SheetsDirective> | ||
| <SheetDirective> | ||
| <RangesDirective> | ||
| <RangeDirective dataSource={data}></RangeDirective> | ||
| </RangesDirective> | ||
| <ColumnsDirective> | ||
| <ColumnDirective width={130}></ColumnDirective> | ||
| <ColumnDirective width={100}></ColumnDirective> | ||
| <ColumnDirective width={100}></ColumnDirective> | ||
| </ColumnsDirective> | ||
| </SheetDirective> | ||
| </SheetsDirective> | ||
| </SpreadsheetComponent> | ||
| </div> | ||
| ); | ||
| }; | ||
| export default App; | ||
|
|
||
| const root = createRoot(document.getElementById('root')); | ||
| root.render(<App />); |
69 changes: 69 additions & 0 deletions
69
Document-Processing/code-snippet/spreadsheet/react/clipboard-cs3/app/app.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import * as React from 'react'; | ||
| import { createRoot } from 'react-dom/client'; | ||
| import { SpreadsheetComponent, SheetsDirective, SheetDirective, RangesDirective } from '@syncfusion/ej2-react-spreadsheet'; | ||
| import { RangeDirective, ColumnsDirective, ColumnDirective } from '@syncfusion/ej2-react-spreadsheet'; | ||
| import { data } from './datasource'; | ||
|
|
||
| function App() { | ||
| let spreadsheet: SpreadsheetComponent; | ||
| const spreadsheetRef = React.useRef<SpreadsheetComponent>(null); | ||
| const onCreated = () => { | ||
| spreadsheet = spreadsheetRef.current; | ||
| spreadsheet.cellFormat({ backgroundColor: '#357cd2', color: '#fff', fontWeight: 'bold', textAlign: 'center' }, 'A1:H1'); | ||
| } | ||
|
|
||
| const actionBegin = (args) => { | ||
| console.log('actionBegin triggered'); | ||
| } | ||
|
|
||
| const beforeCellSave = (args) => { | ||
| console.log('beforeCellSave triggered') | ||
| } | ||
|
|
||
| const beforeCellUpdate = (args) => { | ||
| console.log('beforeCellUpdate triggered'); | ||
| } | ||
|
|
||
| const cellEdit = (args) => { | ||
| console.log('cellEdit triggered'); | ||
| } | ||
|
|
||
| const cellEditing = (args) => { | ||
| console.log('cellEditing triggered') | ||
| } | ||
|
|
||
| const cellEdited = (args) => { | ||
| console.log('cellEdited triggered'); | ||
| } | ||
|
|
||
| const cellSave = (args) => { | ||
| console.log('cellSave triggered') | ||
| } | ||
|
|
||
| const actionComplete = (args) => { | ||
| console.log('actionComplete triggered'); | ||
| } | ||
|
|
||
| return ( | ||
| <div> | ||
| <SpreadsheetComponent ref={spreadsheetRef} created={onCreated} actionBegin={actionBegin} beforeCellSave={beforeCellSave} beforeCellUpdate={beforeCellUpdate} cellSave={cellSave} cellEdit={cellEdit} cellEditing={cellEditing} cellEdited={cellEdited} actionComplete={actionComplete} > | ||
| <SheetsDirective> | ||
| <SheetDirective> | ||
| <RangesDirective> | ||
| <RangeDirective dataSource={data}></RangeDirective> | ||
| </RangesDirective> | ||
| <ColumnsDirective> | ||
| <ColumnDirective width={130}></ColumnDirective> | ||
| <ColumnDirective width={100}></ColumnDirective> | ||
| <ColumnDirective width={100}></ColumnDirective> | ||
| </ColumnsDirective> | ||
| </SheetDirective> | ||
| </SheetsDirective> | ||
| </SpreadsheetComponent> | ||
| </div> | ||
| ); | ||
| }; | ||
| export default App; | ||
|
|
||
| const root = createRoot(document.getElementById('root')!); | ||
| root.render(<App />); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove 'only'