react-gridix 0.2.5 → 0.2.7
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 +109 -3
- 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
|
|
|
@@ -128,7 +128,7 @@ import logo from "./logo.png";
|
|
|
128
128
|
``
|
|
129
129
|
|
|
130
130
|
Without `libraries`, or if an import fails, a PDF export reports an error that says what to install (see `onExportError`) and everything else keeps working.
|
|
131
|
-
|
|
131
|
+
```
|
|
132
132
|
---
|
|
133
133
|
|
|
134
134
|
## 3. Quick start
|
|
@@ -534,6 +534,36 @@ const columns: ColumnDef<Employee>[] = [
|
|
|
534
534
|
{ field: "hired", headerName: "Hired", type: "date", sortable: true, filterable: true },
|
|
535
535
|
];
|
|
536
536
|
```
|
|
537
|
+
```tsx
|
|
538
|
+
const columns: ColumnDef<User>[] = [
|
|
539
|
+
// all eight comparisons
|
|
540
|
+
{ field: "name", headerName: "Name", filterable: true, filterOperators: true },
|
|
541
|
+
|
|
542
|
+
// only some of them, with a different one selected first
|
|
543
|
+
{
|
|
544
|
+
field: "email",
|
|
545
|
+
headerName: "Email",
|
|
546
|
+
filterable: true,
|
|
547
|
+
filterOperators: ["contains", "startsWith", "endsWith", "equals"],
|
|
548
|
+
filterOperator: "startsWith",
|
|
549
|
+
},
|
|
550
|
+
|
|
551
|
+
// no filterOperators: a plain box that always means "contains"
|
|
552
|
+
{ field: "city", headerName: "City", filterable: true },
|
|
553
|
+
];
|
|
554
|
+
```
|
|
555
|
+
##### summary
|
|
556
|
+
| Value | Label shown |
|
|
557
|
+
| --- | --- |
|
|
558
|
+
| `"contains"` | Contains |
|
|
559
|
+
| `"notContains"` | Does not contain |
|
|
560
|
+
| `"equals"` | Equals |
|
|
561
|
+
| `"notEquals"` | Not equal |
|
|
562
|
+
| `"startsWith"` | Starts with |
|
|
563
|
+
| `"notStartsWith"` | Does not start with |
|
|
564
|
+
| `"endsWith"` | Ends with |
|
|
565
|
+
| `"notEndsWith"` | Does not end with |
|
|
566
|
+
|
|
537
567
|
|
|
538
568
|
| Option | Type | Description |
|
|
539
569
|
| --- | --- | --- |
|
|
@@ -579,6 +609,7 @@ const columns: ColumnDef<Employee>[] = [
|
|
|
579
609
|
| `checkbox` | `ColumnCheckboxOptions` | Look of the checkbox in a `type: "boolean"` column: `variant`, `indicator`, `className`, `style`, `classNames`, `styles` |
|
|
580
610
|
| `headerCheckbox` | `boolean` | On a `type: "boolean"` column, draws a select-all checkbox in the header. See [Select-all header checkbox](#select-all-header-checkbox) |
|
|
581
611
|
|
|
612
|
+
|
|
582
613
|
#### Row numbers (sequence column)
|
|
583
614
|
|
|
584
615
|
`type: "sequence"` adds a column of row numbers. It needs no data in your rows: give it a `field` that starts with `#` (so it can never clash with a real field) and a header.
|
|
@@ -2654,7 +2685,82 @@ function NothingHere({ reason, clearAll, search }: EmptyStateProps<User>) {
|
|
|
2654
2685
|
- When rows are removed with an exit animation, the component appears once the last row has left.
|
|
2655
2686
|
- Keep using `emptyMessage` for a plain sentence. `emptyComponent` wins when both are set.
|
|
2656
2687
|
|
|
2657
|
-
### 6.27
|
|
2688
|
+
### 6.27 Column widths
|
|
2689
|
+
|
|
2690
|
+
`width` takes a number (pixels) or any CSS length. `minWidth` and `maxWidth` limit the column.
|
|
2691
|
+
|
|
2692
|
+
```tsx
|
|
2693
|
+
const columns = [
|
|
2694
|
+
{ field: "id", header: "ID", width: 70 }, // 70 px
|
|
2695
|
+
{ field: "name", header: "Name", width: "30%" }, // a share of the grid
|
|
2696
|
+
{ field: "email", header: "Email", width: "16rem" }, // any CSS length
|
|
2697
|
+
{ field: "notes", header: "Notes", minWidth: 200 }, // no width: takes the space that is left
|
|
2698
|
+
];
|
|
2699
|
+
```
|
|
2700
|
+
|
|
2701
|
+
- When any column has a `width`, the grid uses a fixed table layout, so the browser takes your widths literally.
|
|
2702
|
+
- If **every** column has a numeric width, the table is exactly as wide as their sum (it does not stretch).
|
|
2703
|
+
- Columns without a `width` share the remaining space.
|
|
2704
|
+
- Dragging a column border still works and overrides the starting width (limited by `minWidth` / `maxWidth`).
|
|
2705
|
+
|
|
2706
|
+
### 6.28 Sticky toolbar and header, and scroll bars
|
|
2707
|
+
|
|
2708
|
+
**With an inner scroll box** (`maxHeight`) the header already stays at the top and the toolbar and footer stay outside the scrolling part:
|
|
2709
|
+
|
|
2710
|
+
```tsx
|
|
2711
|
+
<DataGrid rows={rows} columns={columns} maxHeight="60vh" />
|
|
2712
|
+
```
|
|
2713
|
+
|
|
2714
|
+
**While the whole page scrolls** (optional, off by default):
|
|
2715
|
+
|
|
2716
|
+
```tsx
|
|
2717
|
+
<DataGrid rows={rows} columns={columns} stickyToolbar stickyHeader />
|
|
2718
|
+
|
|
2719
|
+
// Under a fixed top bar of your own that is 64px tall
|
|
2720
|
+
<DataGrid rows={rows} columns={columns} stickyToolbar stickyHeader stickyOffset={64} />
|
|
2721
|
+
|
|
2722
|
+
// Only the header
|
|
2723
|
+
<DataGrid rows={rows} columns={columns} stickyHeader stickyOffset="4rem" />
|
|
2724
|
+
```
|
|
2725
|
+
|
|
2726
|
+
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.
|
|
2727
|
+
|
|
2728
|
+
**Scroll bars inside the grid** are thin by default. Use `scrollbar` to change them:
|
|
2729
|
+
|
|
2730
|
+
```tsx
|
|
2731
|
+
<DataGrid scrollbar="thin" /> // default: slim bar
|
|
2732
|
+
<DataGrid scrollbar="auto" /> // the browser's normal bar
|
|
2733
|
+
<DataGrid scrollbar="hidden" /> // no bar, scrolling still works
|
|
2734
|
+
<DataGrid scrollbar="custom" /> // no style from the grid: your CSS applies
|
|
2735
|
+
```
|
|
2736
|
+
|
|
2737
|
+
Colours of the thin bar come from CSS variables:
|
|
2738
|
+
|
|
2739
|
+
```css
|
|
2740
|
+
.my-grid {
|
|
2741
|
+
--rg-scrollbar-thumb: #6366f1; /* the moving part */
|
|
2742
|
+
--rg-scrollbar-track: #eef2ff; /* the rail */
|
|
2743
|
+
--rg-scrollbar-width: auto; /* thin | auto | none */
|
|
2744
|
+
}
|
|
2745
|
+
```
|
|
2746
|
+
|
|
2747
|
+
Full control (size, rounded ends, hover colour) with `scrollbar="custom"`:
|
|
2748
|
+
|
|
2749
|
+
```tsx
|
|
2750
|
+
<DataGrid scrollbar="custom" classNames={{ scroll: "my-scroll" }} />
|
|
2751
|
+
```
|
|
2752
|
+
|
|
2753
|
+
```css
|
|
2754
|
+
.my-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
|
|
2755
|
+
.my-scroll::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 999px; }
|
|
2756
|
+
.my-scroll::-webkit-scrollbar-thumb:hover { background: #475569; }
|
|
2757
|
+
.my-scroll { scrollbar-width: thin; scrollbar-color: #94a3b8 transparent; } /* Firefox */
|
|
2758
|
+
```
|
|
2759
|
+
|
|
2760
|
+
The list of options in a `filterType: "select"` popup scrolls without showing a scroll bar.
|
|
2761
|
+
|
|
2762
|
+
|
|
2763
|
+
### 6.29 Known limitations
|
|
2658
2764
|
|
|
2659
2765
|
Not included:
|
|
2660
2766
|
|