react-gridix 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +121 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# React-gridix
|
|
2
2
|
|
|
3
3
|
A React `DataGrid` with row selection, server-side mode, typed per-column filters, date columns, in-cell editing, resizing and pinning, virtualization, export to CSV / Excel / JSON / PDF, 12 row animations, filter comparisons and 8 themes, plus the `Checkbox` it uses.
|
|
4
4
|
|
|
@@ -1513,6 +1513,50 @@ Other slots work the same way: `root`, `toolbar`, `search`, `table`, `thead`, `h
|
|
|
1513
1513
|
#### Width
|
|
1514
1514
|
|
|
1515
1515
|
The grid is `width: 100%` of its container by default (it never overflows it: `max-width: 100%; min-width: 0`). To make it narrower, give it a width through `className` (`max-w-3xl`) or `style` (`{ maxWidth: 900 }`).
|
|
1516
|
+
## `overflow` column option
|
|
1517
|
+
|
|
1518
|
+
Controls what happens to text that doesn't fit the column, in both the header and the cells.
|
|
1519
|
+
|
|
1520
|
+
| Value | Behavior | Example (width 60) |
|
|
1521
|
+
|---|---|---|
|
|
1522
|
+
| `"wrap"` | Breaks the text onto new lines, even inside a word | `Alexa` / `nder` |
|
|
1523
|
+
| `"ellipsis"` | Cuts the text and shows `...` | `Alexa...` |
|
|
1524
|
+
| `"clip"` | Cuts the text, no dots | `Alexa` |
|
|
1525
|
+
|
|
1526
|
+
**Default** (when `overflow` is not set):
|
|
1527
|
+
|
|
1528
|
+
- Column has a `width`: `"wrap"`
|
|
1529
|
+
- Numeric `width` under 40: `"clip"`
|
|
1530
|
+
- No `width`: the grid's normal behavior
|
|
1531
|
+
|
|
1532
|
+
### Example
|
|
1533
|
+
|
|
1534
|
+
```tsx
|
|
1535
|
+
const columns: ColumnDef<Person>[] = [
|
|
1536
|
+
{ field: "color", header: "", width: 6 }, // thin strip, "clip" by default
|
|
1537
|
+
{ field: "id", header: "ID", width: 50 }, // "wrap" by default
|
|
1538
|
+
{ field: "name", header: "Name", width: 120, overflow: "ellipsis" }, // "Alexander Ha..."
|
|
1539
|
+
{ field: "notes", header: "Notes", width: 200, overflow: "wrap" }, // new lines
|
|
1540
|
+
{ field: "code", header: "Code", width: 80, overflow: "clip" }, // cut off
|
|
1541
|
+
];
|
|
1542
|
+
```
|
|
1543
|
+
|
|
1544
|
+
### Notes
|
|
1545
|
+
|
|
1546
|
+
- Widths under 40 also remove the column's side padding, so `width: 1` really is 1px.
|
|
1547
|
+
- `"wrap"` in a very narrow column puts one character per line and makes rows tall. Use `"ellipsis"` or `"clip"` there.
|
|
1548
|
+
- To show the full text on hover, add a tooltip in a `cellRenderer`:
|
|
1549
|
+
|
|
1550
|
+
```tsx
|
|
1551
|
+
{
|
|
1552
|
+
field: "name",
|
|
1553
|
+
header: "Name",
|
|
1554
|
+
width: 120,
|
|
1555
|
+
overflow: "ellipsis",
|
|
1556
|
+
cellRenderer: ({ value }) => <span title={String(value)}>{String(value)}</span>,
|
|
1557
|
+
}
|
|
1558
|
+
```
|
|
1559
|
+
|
|
1516
1560
|
|
|
1517
1561
|
#### Plain CSS class reference
|
|
1518
1562
|
|
|
@@ -2685,7 +2729,82 @@ function NothingHere({ reason, clearAll, search }: EmptyStateProps<User>) {
|
|
|
2685
2729
|
- When rows are removed with an exit animation, the component appears once the last row has left.
|
|
2686
2730
|
- Keep using `emptyMessage` for a plain sentence. `emptyComponent` wins when both are set.
|
|
2687
2731
|
|
|
2688
|
-
### 6.27
|
|
2732
|
+
### 6.27 Column widths
|
|
2733
|
+
|
|
2734
|
+
`width` takes a number (pixels) or any CSS length. `minWidth` and `maxWidth` limit the column.
|
|
2735
|
+
|
|
2736
|
+
```tsx
|
|
2737
|
+
const columns = [
|
|
2738
|
+
{ field: "id", header: "ID", width: 70 }, // 70 px
|
|
2739
|
+
{ field: "name", header: "Name", width: "30%" }, // a share of the grid
|
|
2740
|
+
{ field: "email", header: "Email", width: "16rem" }, // any CSS length
|
|
2741
|
+
{ field: "notes", header: "Notes", minWidth: 200 }, // no width: takes the space that is left
|
|
2742
|
+
];
|
|
2743
|
+
```
|
|
2744
|
+
|
|
2745
|
+
- When any column has a `width`, the grid uses a fixed table layout, so the browser takes your widths literally.
|
|
2746
|
+
- If **every** column has a numeric width, the table is exactly as wide as their sum (it does not stretch).
|
|
2747
|
+
- Columns without a `width` share the remaining space.
|
|
2748
|
+
- Dragging a column border still works and overrides the starting width (limited by `minWidth` / `maxWidth`).
|
|
2749
|
+
|
|
2750
|
+
### 6.28 Sticky toolbar and header, and scroll bars
|
|
2751
|
+
|
|
2752
|
+
**With an inner scroll box** (`maxHeight`) the header already stays at the top and the toolbar and footer stay outside the scrolling part:
|
|
2753
|
+
|
|
2754
|
+
```tsx
|
|
2755
|
+
<DataGrid rows={rows} columns={columns} maxHeight="60vh" />
|
|
2756
|
+
```
|
|
2757
|
+
|
|
2758
|
+
**While the whole page scrolls** (optional, off by default):
|
|
2759
|
+
|
|
2760
|
+
```tsx
|
|
2761
|
+
<DataGrid rows={rows} columns={columns} stickyToolbar stickyHeader />
|
|
2762
|
+
|
|
2763
|
+
// Under a fixed top bar of your own that is 64px tall
|
|
2764
|
+
<DataGrid rows={rows} columns={columns} stickyToolbar stickyHeader stickyOffset={64} />
|
|
2765
|
+
|
|
2766
|
+
// Only the header
|
|
2767
|
+
<DataGrid rows={rows} columns={columns} stickyHeader stickyOffset="4rem" />
|
|
2768
|
+
```
|
|
2769
|
+
|
|
2770
|
+
The header sits right under the toolbar when both are sticky. In this mode the grid has no scroll box of its own, so a table wider than the page overflows: give the columns widths that fit (see 6.28). It is ignored when `maxHeight` or `virtualize` is set, because those already scroll inside the grid.
|
|
2771
|
+
|
|
2772
|
+
**Scroll bars inside the grid** are thin by default. Use `scrollbar` to change them:
|
|
2773
|
+
|
|
2774
|
+
```tsx
|
|
2775
|
+
<DataGrid scrollbar="thin" /> // default: slim bar
|
|
2776
|
+
<DataGrid scrollbar="auto" /> // the browser's normal bar
|
|
2777
|
+
<DataGrid scrollbar="hidden" /> // no bar, scrolling still works
|
|
2778
|
+
<DataGrid scrollbar="custom" /> // no style from the grid: your CSS applies
|
|
2779
|
+
```
|
|
2780
|
+
|
|
2781
|
+
Colours of the thin bar come from CSS variables:
|
|
2782
|
+
|
|
2783
|
+
```css
|
|
2784
|
+
.my-grid {
|
|
2785
|
+
--rg-scrollbar-thumb: #6366f1; /* the moving part */
|
|
2786
|
+
--rg-scrollbar-track: #eef2ff; /* the rail */
|
|
2787
|
+
--rg-scrollbar-width: auto; /* thin | auto | none */
|
|
2788
|
+
}
|
|
2789
|
+
```
|
|
2790
|
+
|
|
2791
|
+
Full control (size, rounded ends, hover colour) with `scrollbar="custom"`:
|
|
2792
|
+
|
|
2793
|
+
```tsx
|
|
2794
|
+
<DataGrid scrollbar="custom" classNames={{ scroll: "my-scroll" }} />
|
|
2795
|
+
```
|
|
2796
|
+
|
|
2797
|
+
```css
|
|
2798
|
+
.my-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
|
|
2799
|
+
.my-scroll::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 999px; }
|
|
2800
|
+
.my-scroll::-webkit-scrollbar-thumb:hover { background: #475569; }
|
|
2801
|
+
.my-scroll { scrollbar-width: thin; scrollbar-color: #94a3b8 transparent; } /* Firefox */
|
|
2802
|
+
```
|
|
2803
|
+
|
|
2804
|
+
The list of options in a `filterType: "select"` popup scrolls without showing a scroll bar.
|
|
2805
|
+
|
|
2806
|
+
|
|
2807
|
+
### 6.29 Known limitations
|
|
2689
2808
|
|
|
2690
2809
|
Not included:
|
|
2691
2810
|
|