|
2 | 2 |
|
3 | 3 | ## HTML/CSS Prerequisites |
4 | 4 |
|
5 | | -Currently the Grid depends on there being a root level "portal" div in your HTML. Insert this snippet as the last child of your `<body>` tag: |
| 5 | +The Grid depends on there being a root level "portal" div in your HTML. Insert this snippet as the last child of your `<body>` tag: |
6 | 6 |
|
7 | 7 | ```HTML |
8 | 8 | <div id="portal" style="position: fixed; left: 0; top: 0; z-index: 9999;" /> |
9 | 9 | ``` |
10 | 10 |
|
| 11 | +or you can create a portal element yourself using the `createPortal` function from `react-dom` and pass it to the DataEditor via the `portalElementRef` prop. |
| 12 | + |
| 13 | +```jsx |
| 14 | +const portalRef = useRef(null); |
| 15 | +<> |
| 16 | + { |
| 17 | + createPortal( |
| 18 | + <div ref={portalRef} style="position: fixed; left: 0; top: 0; z-index: 9999;" />, |
| 19 | + document.body |
| 20 | + ) |
| 21 | + } |
| 22 | + <DataEditor width={500} height={300} portalElementRef={portalRef} {...props} /> |
| 23 | +</> |
| 24 | +``` |
| 25 | + |
11 | 26 | Once you've got that done, the easiest way to use the Data Grid is to give it a fixed size: |
12 | 27 |
|
13 | 28 | ```jsx |
@@ -71,14 +86,15 @@ All data grids must set these props. These props are the bare minimum required t |
71 | 86 | Most data grids will want to set the majority of these props one way or another. |
72 | 87 |
|
73 | 88 | | Name | Description | |
74 | | -| ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 89 | +|---------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
75 | 90 | | [fixedShadowX](#fixedshadow) | Enable/disable a shadow behind fixed columns on the X axis. | |
76 | 91 | | [fixedShadowY](#fixedshadow) | Enable/disable a shadow behind the header(s) on the Y axis. | |
77 | 92 | | [freezeColumns](#freezecolumns) | The number of columns which should remain in place when scrolling horizontally. The row marker column, if enabled is always frozen and is not included in this count. | |
78 | 93 | | [getCellsForSelection](#getcellsforselection) | Used to fetch large amounts of cells at once. Used for copy/paste, if unset copy will not work. | |
79 | 94 | | [markdownDivCreateNode](#markdowndivcreatenode) | If specified, it will be used to render Markdown, instead of the default Markdown renderer used by the Grid. You'll want to use this if you need to process your Markdown for security purposes, or if you want to use a renderer with different Markdown features. | |
80 | 95 | | [onVisibleRegionChanged](#onvisibleregionchanged) | Emits whenever the visible rows/columns changes. | |
81 | 96 | | [provideEditor](#provideeditor) | Callback for providing a custom editor for a cell. | |
| 97 | +| [portalElementRef](#portalelementref) | A ref to the portal element to use for the overlay editor. | |
82 | 98 | | [rowHeight](#rowheight) | Callback or number used to specify the height of a given row. | |
83 | 99 | | [rowMarkers](#rowmarkers) | Enable/disable row marker column on the left. Can show row numbers, selection boxes, or both. | |
84 | 100 | | [smoothScrollX](#smoothscroll) | Enable/disable smooth scrolling on the X axis. | |
@@ -610,6 +626,12 @@ When provided the `provideEditor` callbacks job is to be a constructor for funct |
610 | 626 |
|
611 | 627 | --- |
612 | 628 |
|
| 629 | +## portalElementRef |
| 630 | + |
| 631 | +Defaults to div#portal |
| 632 | + |
| 633 | +--- |
| 634 | + |
613 | 635 | ## rowHeight |
614 | 636 |
|
615 | 637 | ```ts |
|
0 commit comments