-
Notifications
You must be signed in to change notification settings - Fork 14
Documentation(EJ2-1015310): Add content for integrate spreadsheet into existing layouts in react spreadsheet ug documentation. #2459
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
NITHISHKUMARRAVIKUMAR
wants to merge
12
commits into
development
Choose a base branch
from
EJ2-1015310-ug1
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.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a7662c8
1015310: added content for integrating spreadsheet into existing layo…
Nithishk1 be5d621
Merge branch 'development' of https://github.com/syncfusion-content/d…
Nithishk1 cf0726d
1015310: added content for integrating spreadsheet into existing layo…
Nithishk1 c8bec29
1015310: added code samples for integrating spreadsheet into existing…
Nithishk1 6d5c375
Merge branch 'development' of https://github.com/syncfusion-content/d…
Nithishk1 ac57c9d
Merge branch 'development' of https://github.com/syncfusion-content/d…
Nithishk1 bb4668a
1015310: added code samples for integrating spreadsheet into existing…
Nithishk1 b965eef
Merge branch 'development' of https://github.com/syncfusion-content/d…
Nithishk1 deff494
1015310: added code samples for integrate spreadsheet into existing l…
Nithishk1 4d01b24
Merge branch 'development' of https://github.com/syncfusion-content/d…
Nithishk1 ab7ca75
Merge branch 'development' of https://github.com/syncfusion-content/d…
Nithishk1 d4ff0af
1015310: added code samples for integrate spreadsheet into existing l…
Nithishk1 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
91 changes: 91 additions & 0 deletions
91
Document-Processing/Excel/Spreadsheet/React/how-to/existing-react-layout.md
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,91 @@ | ||
| --- | ||
| layout: post | ||
| title: Integrating Spreadsheet into existing React layouts | Syncfusion | ||
| description: Guidance on embedding the Spreadsheet into react layouts using the Syncfusion React Spreadsheet component of Syncfusion Essential JS 2 and more. | ||
| control: Spreadsheet | ||
| platform: document-processing | ||
| documentation: ug | ||
| --- | ||
|
|
||
| # Integrating Spreadsheet into Existing React Layouts | ||
|
|
||
| ## Overview | ||
|
|
||
| The React Spreadsheet component can be embedded into dashboards, admin panels, split‑screen views, tabs, dialogs, collapsible/accordion sections, sidebars, and multi‑column layouts. This guide provides concise layout patterns and minimal code examples to ensure the Spreadsheet renders correctly, resizes properly, and refreshes when hosted inside common layout containers. | ||
|
|
||
| ## How‑To | ||
|
|
||
| ### Use Spreadsheet inside Tab components | ||
|
|
||
| The React Spreadsheet component is supported inside Syncfusion Tab components. | ||
|
|
||
| {% tabs %} | ||
| {% highlight js tabtitle="app.jsx" %} | ||
| {% include code-snippet/spreadsheet/react/integrate-into-layouts-cs1/app/app.jsx %} | ||
| {% endhighlight %} | ||
| {% highlight ts tabtitle="app.tsx" %} | ||
| {% include code-snippet/spreadsheet/react/integrate-into-layouts-cs1/app/app.tsx %} | ||
| {% endhighlight %} | ||
| {% endtabs %} | ||
|
|
||
| {% previewsample "/document-processing/code-snippet/spreadsheet/react/integrate-into-layouts-cs1" %} | ||
|
|
||
| ### Use spreadsheet inside Dialog | ||
|
|
||
| If the spreadsheet sits inside a dialog, for example Syncfusion Dialog, render or initialize the spreadsheet after the dialog open events. The DOM must be visible for the spreadsheet to measure layout. | ||
|
|
||
| {% tabs %} | ||
| {% highlight js tabtitle="app.jsx" %} | ||
| {% include code-snippet/spreadsheet/react/integrate-into-layouts-cs2/app/app.jsx %} | ||
| {% endhighlight %} | ||
| {% highlight ts tabtitle="app.tsx" %} | ||
| {% include code-snippet/spreadsheet/react/integrate-into-layouts-cs2/app/app.tsx %} | ||
| {% endhighlight %} | ||
| {% endtabs %} | ||
|
|
||
| {% previewsample "/document-processing/code-snippet/spreadsheet/react/integrate-into-layouts-cs2" %} | ||
|
|
||
| ### Use Spreadsheet inside collapsible sections | ||
|
|
||
| For accordions or collapsible containers, you can render the Spreadsheet inside an `AccordionItem`. If the item is rendered while hidden, trigger a resize event when the section becomes active so the component can recalculate its layout. | ||
|
|
||
| {% tabs %} | ||
| {% highlight js tabtitle="app.jsx" %} | ||
| {% include code-snippet/spreadsheet/react/integrate-into-layouts-cs3/app/app.jsx %} | ||
| {% endhighlight %} | ||
| {% highlight ts tabtitle="app.tsx" %} | ||
| {% include code-snippet/spreadsheet/react/integrate-into-layouts-cs3/app/app.tsx %} | ||
| {% endhighlight %} | ||
| {% endtabs %} | ||
|
|
||
| {% previewsample "/document-processing/code-snippet/spreadsheet/react/integrate-into-layouts-cs3" %} | ||
|
|
||
| ## Why visibility and height matter | ||
|
|
||
| The Spreadsheet measures its host container to calculate column widths, row heights and layout. If the host element has no height (collapsed, `display:none`, or not yet mounted) measurements will be zero and the Spreadsheet may render incorrectly, be clipped, or not display at all. | ||
|
|
||
| Initialize or refresh the Spreadsheet when its host becomes visible (tab active, modal opened, accordion expanded) so internal layout code can compute sizes. | ||
|
|
||
| ## Resize & visibility tips | ||
|
|
||
| After the host becomes visible, call the Spreadsheet instance's [resize](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#resize) method so it can recompute layout: | ||
|
|
||
| ```js | ||
| setTimeout(() => { | ||
| spreadsheetRef.current.resize(); | ||
| }, 0); | ||
| ``` | ||
|
|
||
| Lazy-render inside tabs/dialogs/accordions: only mount the Spreadsheet when the pane is visible. If you must mount while hidden, call `spreadsheetRef.current.resize()` after showing so the Spreadsheet recomputes layout. | ||
|
|
||
| ## When to use these patterns | ||
|
|
||
| - Use Dialogs for temporary or isolated spreadsheet previews. | ||
| - Use Tabs/Accordion patterns for multi-pane UIs — ensure a resize/refresh is triggered when a pane becomes active. | ||
| - Avoid placing the Spreadsheet in invisible containers without a resize/refresh strategy; otherwise measurements will be zero and layout will break. | ||
|
|
||
| ## See also | ||
|
|
||
| - [Overview of Syncfusion React Tab component](https://ej2.syncfusion.com/react/documentation/tab/getting-started) | ||
| - [Overview of Syncfusion React Dialog component](https://ej2.syncfusion.com/react/documentation/dialog/getting-started) | ||
| - [Overview of Syncfusion React Accordion component](https://ej2.syncfusion.com/react/documentation/accordion/getting-started) | ||
59 changes: 59 additions & 0 deletions
59
Document-Processing/code-snippet/spreadsheet/react/integrate-into-layouts-cs1/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,59 @@ | ||
| import * as React from 'react'; | ||
| import { createRoot } from 'react-dom/client'; | ||
| import { SpreadsheetComponent } from '@syncfusion/ej2-react-spreadsheet'; | ||
| import { TabComponent, TabItemsDirective, TabItemDirective } from '@syncfusion/ej2-react-navigations'; | ||
|
|
||
| function App() { | ||
|
|
||
| const SpreadsheetTabContent = () => { | ||
| return ( | ||
| <div className="spreadsheet-pane"> | ||
| <div> | ||
| <SpreadsheetComponent height="100%" width="100%" /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="page"> | ||
| <header className="header"> | ||
| <h3 style={{ margin: 0 }}>Spreadsheet in tab</h3> | ||
| </header> | ||
|
|
||
| <div className="tab-host"> | ||
| <TabComponent height="100%"> | ||
| <TabItemsDirective> | ||
| <TabItemDirective | ||
| header={{ text: 'Overview' }} | ||
| content={() => ( | ||
| <div className="panel"> | ||
| <h4>Overview</h4> | ||
| <p>Put general dashboard content here.</p> | ||
| </div> | ||
| )} | ||
| /> | ||
| <TabItemDirective | ||
| header={{ text: 'Spreadsheet' }} | ||
| content={SpreadsheetTabContent} | ||
| /> | ||
| <TabItemDirective | ||
| header={{ text: 'Settings' }} | ||
| content={() => ( | ||
| <div className="panel"> | ||
| <h4>Settings</h4> | ||
| <p>Any settings or forms can go here.</p> | ||
| </div> | ||
| )} | ||
| /> | ||
| </TabItemsDirective> | ||
| </TabComponent> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default App; | ||
|
|
||
| const root = createRoot(document.getElementById('root')); | ||
| root.render(<App />); |
59 changes: 59 additions & 0 deletions
59
Document-Processing/code-snippet/spreadsheet/react/integrate-into-layouts-cs1/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,59 @@ | ||
| import * as React from 'react'; | ||
| import { createRoot } from 'react-dom/client'; | ||
| import { SpreadsheetComponent } from '@syncfusion/ej2-react-spreadsheet'; | ||
| import { TabComponent, TabItemsDirective, TabItemDirective } from '@syncfusion/ej2-react-navigations'; | ||
|
|
||
| function App(): React.ReactElement { | ||
|
|
||
| const SpreadsheetTabContent: any = () => { | ||
| return ( | ||
| <div className="spreadsheet-pane"> | ||
| <div> | ||
| <SpreadsheetComponent height="100%" width="100%" /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="page"> | ||
| <header className="header"> | ||
| <h3 style={{ margin: 0 }}>Spreadsheet in tab</h3> | ||
| </header> | ||
|
|
||
| <div className="tab-host"> | ||
| <TabComponent height="100%"> | ||
| <TabItemsDirective> | ||
| <TabItemDirective | ||
| header={{ text: 'Overview' }} | ||
| content={() => ( | ||
| <div className="panel"> | ||
| <h4>Overview</h4> | ||
| <p>Put general dashboard content here.</p> | ||
| </div> | ||
| )} | ||
| /> | ||
| <TabItemDirective | ||
| header={{ text: 'Spreadsheet' }} | ||
| content={SpreadsheetTabContent} | ||
| /> | ||
| <TabItemDirective | ||
| header={{ text: 'Settings' }} | ||
| content={() => ( | ||
| <div className="panel"> | ||
| <h4>Settings</h4> | ||
| <p>Any settings or forms can go here.</p> | ||
| </div> | ||
| )} | ||
| /> | ||
| </TabItemsDirective> | ||
| </TabComponent> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default App; | ||
|
|
||
| const root = createRoot(document.getElementById('root')!); | ||
| root.render(<App />); |
36 changes: 36 additions & 0 deletions
36
Document-Processing/code-snippet/spreadsheet/react/integrate-into-layouts-cs1/index.html
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,36 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
|
|
||
| <head> | ||
| <title>Syncfusion React Spreadsheet</title> | ||
| <meta charset="utf-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <meta name="description" content="Essential JS 2 for React Components" /> | ||
| <meta name="author" content="Syncfusion" /> | ||
| <link href="https://cdn.syncfusion.com/ej2/33.1.44/tailwind3.css" rel="stylesheet" type="text/css" /> | ||
| <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> | ||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script> | ||
| <script src="systemjs.config.js"></script> | ||
| <style> | ||
| #loader { | ||
| color: #008cff; | ||
| height: 40px; | ||
| left: 45%; | ||
| position: absolute; | ||
| top: 45%; | ||
| width: 30%; | ||
| } | ||
|
|
||
| body { | ||
| overflow: hidden; | ||
| } | ||
| </style> | ||
| </head> | ||
|
|
||
| <body> | ||
| <div id='root'> | ||
| <div id='loader'>Loading....</div> | ||
| </div> | ||
| </body> | ||
|
|
||
| </html> |
56 changes: 56 additions & 0 deletions
56
...t-Processing/code-snippet/spreadsheet/react/integrate-into-layouts-cs1/systemjs.config.js
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,56 @@ | ||
| System.config({ | ||
| transpiler: "ts", | ||
| typescriptOptions: { | ||
| target: "es5", | ||
| module: "commonjs", | ||
| moduleResolution: "node", | ||
| emitDecoratorMetadata: true, | ||
| experimentalDecorators: true, | ||
| "jsx": "react" | ||
| }, | ||
| meta: { | ||
| 'typescript': { | ||
| "exports": "ts" | ||
| } | ||
| }, | ||
| paths: { | ||
| "syncfusion:": "https://cdn.syncfusion.com/ej2/33.1.44/" | ||
| }, | ||
| map: { | ||
| app: 'app', | ||
| ts: "https://unpkg.com/plugin-typescript@4.0.10/lib/plugin.js", | ||
| typescript: "https://unpkg.com/typescript@2.2.2/lib/typescript.js", | ||
| "@syncfusion/ej2-base": "syncfusion:ej2-base/dist/ej2-base.umd.min.js", | ||
| "@syncfusion/ej2-data": "syncfusion:ej2-data/dist/ej2-data.umd.min.js", | ||
| "@syncfusion/ej2-lists": "syncfusion:ej2-lists/dist/ej2-lists.umd.min.js", | ||
| "@syncfusion/ej2-navigations": "syncfusion:ej2-navigations/dist/ej2-navigations.umd.min.js", | ||
| "@syncfusion/ej2-notifications": "syncfusion:ej2-notifications/dist/ej2-notifications.umd.min.js", | ||
| "@syncfusion/ej2-popups": "syncfusion:ej2-popups/dist/ej2-popups.umd.min.js", | ||
| "@syncfusion/ej2-dropdowns": "syncfusion:ej2-dropdowns/dist/ej2-dropdowns.umd.min.js", | ||
| "@syncfusion/ej2-inputs": "syncfusion:ej2-inputs/dist/ej2-inputs.umd.min.js", | ||
| "@syncfusion/ej2-splitbuttons": "syncfusion:ej2-splitbuttons/dist/ej2-splitbuttons.umd.min.js", | ||
| "@syncfusion/ej2-buttons": "syncfusion:ej2-buttons/dist/ej2-buttons.umd.min.js", | ||
| "@syncfusion/ej2-calendars": "syncfusion:ej2-calendars/dist/ej2-calendars.umd.min.js", | ||
| "@syncfusion/ej2-excel-export": "syncfusion:ej2-excel-export/dist/ej2-excel-export.umd.min.js", | ||
| "@syncfusion/ej2-pdf-export": "syncfusion:ej2-pdf-export/dist/ej2-pdf-export.umd.min.js", | ||
| "@syncfusion/ej2-file-utils": "syncfusion:ej2-file-utils/dist/ej2-file-utils.umd.min.js", | ||
| "@syncfusion/ej2-compression": "syncfusion:ej2-compression/dist/ej2-compression.umd.min.js", | ||
| "@syncfusion/ej2-grids": "syncfusion:ej2-grids/dist/ej2-grids.umd.min.js", | ||
| "@syncfusion/ej2-charts": "syncfusion:ej2-charts/dist/ej2-charts.umd.min.js", | ||
| "@syncfusion/ej2-svg-base": "syncfusion:ej2-svg-base/dist/ej2-svg-base.umd.min.js", | ||
| "@syncfusion/ej2-spreadsheet": "syncfusion:ej2-spreadsheet/dist/ej2-spreadsheet.umd.min.js", | ||
| "@syncfusion/ej2-react-base": "syncfusion:ej2-react-base/dist/ej2-react-base.umd.min.js", | ||
| "@syncfusion/ej2-react-spreadsheet": "syncfusion:ej2-react-spreadsheet/dist/ej2-react-spreadsheet.umd.min.js", | ||
| "@syncfusion/ej2-react-navigations": "syncfusion:ej2-react-navigations/dist/ej2-react-navigations.umd.min.js", | ||
| "react-dom/client": "https://unpkg.com/react-dom@18.2.0/umd/react-dom.production.min.js", | ||
| "react-dom": "https://unpkg.com/react-dom@18.2.0/umd/react-dom.production.min.js", | ||
| "react": "https://unpkg.com/react@18.2.0/umd/react.production.min.js", | ||
|
|
||
| }, | ||
| packages: { | ||
| 'app': { main: 'app', defaultExtension: 'tsx' }, | ||
| } | ||
|
|
||
| }); | ||
|
|
||
| System.import('app'); |
56 changes: 56 additions & 0 deletions
56
Document-Processing/code-snippet/spreadsheet/react/integrate-into-layouts-cs2/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,56 @@ | ||
| import * as React from 'react'; | ||
| import { useRef, useCallback } from 'react'; | ||
| import { createRoot } from 'react-dom/client'; | ||
| import { SpreadsheetComponent } from '@syncfusion/ej2-react-spreadsheet'; | ||
| import { DialogComponent } from '@syncfusion/ej2-react-popups'; | ||
|
|
||
| function App() { | ||
|
|
||
| const dialogRef = useRef(null); | ||
| const spreadsheetRef = useRef(null); | ||
| const openDialog = () => { | ||
| dialogRef.current.show(); | ||
| }; | ||
| const closeDialog = () => { | ||
| dialogRef.current.hide(); | ||
| }; | ||
| const onDialogOpen = useCallback(() => { | ||
| setTimeout(() => { | ||
| spreadsheetRef.current.resize(); | ||
| }, 0); | ||
| }, []); | ||
|
|
||
| return ( | ||
| <div className="page"> | ||
| <header className="header"> | ||
| <h3 style={{ margin: 0 }}>Spreadsheet inside Dialog</h3> | ||
| <div style={{ marginLeft: 'auto' }}> | ||
| <button onClick={openDialog}>Open Spreadsheet</button> | ||
| </div> | ||
| </header> | ||
| <DialogComponent | ||
| ref={(dlg) => (dialogRef.current = dlg)} | ||
| isModal={true} | ||
| visible={false} | ||
| header="Spreadsheet" | ||
| showCloseIcon={true} | ||
| minHeight="80vh" | ||
| width="80vw" | ||
| height="80vh" | ||
| allowDragging={true} | ||
| closeOnEscape={true} | ||
| target={document.body} | ||
| overlayClick={closeDialog} | ||
| open={onDialogOpen} | ||
| > | ||
| <SpreadsheetComponent height="100%" width="100%" /> | ||
| </DialogComponent> | ||
| </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.
Uh oh!
There was an error while loading. Please reload this page.