@nocopypaste/vue-grid 0.6.0 → 0.8.0
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/AGENTS.md +33 -24
- package/CHANGELOG.md +44 -0
- package/README.md +214 -79
- package/agent/api.json +68 -10
- package/agent/api.md +17 -7
- package/agent/grid-config.schema.json +15 -11
- package/dist/agent/api.js +66 -10
- package/dist/agent/requirements.js +1 -0
- package/dist/agent/requirements.js.map +1 -1
- package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js +583 -522
- package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridCell.vue_vue_type_script_setup_true_lang.js +4 -3
- package/dist/components/VGridCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridColumnMenu.vue_vue_type_script_setup_true_lang.js +58 -53
- package/dist/components/VGridColumnMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridFilterInput.vue_vue_type_script_setup_true_lang.js +50 -49
- package/dist/components/VGridFilterInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridFilterPanel.vue_vue_type_script_setup_true_lang.js +151 -146
- package/dist/components/VGridFilterPanel.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridFilterPopover.vue_vue_type_script_setup_true_lang.js +44 -43
- package/dist/components/VGridFilterPopover.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridGroupCells.vue_vue_type_script_setup_true_lang.js +12 -10
- package/dist/components/VGridGroupCells.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridHeader.vue_vue_type_script_setup_true_lang.js +62 -57
- package/dist/components/VGridHeader.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridMenu.vue_vue_type_script_setup_true_lang.js +59 -58
- package/dist/components/VGridMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridPagination.vue_vue_type_script_setup_true_lang.js +62 -55
- package/dist/components/VGridPagination.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridResizeHandle.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/VGridResizeHandle.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridRows.vue_vue_type_script_setup_true_lang.js +60 -59
- package/dist/components/VGridRows.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridSearch.vue_vue_type_script_setup_true_lang.js +27 -26
- package/dist/components/VGridSearch.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridSelectionBanner.vue_vue_type_script_setup_true_lang.js +12 -11
- package/dist/components/VGridSelectionBanner.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridStatusBar.vue_vue_type_script_setup_true_lang.js +37 -30
- package/dist/components/VGridStatusBar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/composables/useDataSource.js +21 -19
- package/dist/composables/useDataSource.js.map +1 -1
- package/dist/composables/useGridExport.js +22 -7
- package/dist/composables/useGridExport.js.map +1 -1
- package/dist/composables/useGridMenus.js +41 -41
- package/dist/composables/useGridMenus.js.map +1 -1
- package/dist/composables/useRowGrouping.js +103 -74
- package/dist/composables/useRowGrouping.js.map +1 -1
- package/dist/composables/useServerGroups.js +106 -0
- package/dist/composables/useServerGroups.js.map +1 -0
- package/dist/composables/useStatusBar.js +9 -0
- package/dist/composables/useStatusBar.js.map +1 -1
- package/dist/core/grouping.js +41 -24
- package/dist/core/grouping.js.map +1 -1
- package/dist/features/export.js.map +1 -1
- package/dist/features/index.js +12 -10
- package/dist/features/index.js.map +1 -1
- package/dist/features/serverGrouping.js +9 -0
- package/dist/features/serverGrouping.js.map +1 -0
- package/dist/index.js +7 -6
- package/dist/internal/context.js.map +1 -1
- package/dist/internal/features.js.map +1 -1
- package/dist/internal/messages.js +20 -0
- package/dist/internal/messages.js.map +1 -0
- package/dist/internal/print.js +51 -0
- package/dist/internal/print.js.map +1 -0
- package/dist/renderers/ActionsMenuCell.vue_vue_type_script_setup_true_lang.js +31 -30
- package/dist/renderers/ActionsMenuCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/ChangeCell.vue_vue_type_script_setup_true_lang.js +28 -27
- package/dist/renderers/ChangeCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/CopyCell.vue_vue_type_script_setup_true_lang.js +22 -21
- package/dist/renderers/CopyCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/DetailsCell.vue_vue_type_script_setup_true_lang.js +37 -36
- package/dist/renderers/DetailsCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/EditCell.vue_vue_type_script_setup_true_lang.js +16 -15
- package/dist/renderers/EditCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/IconToggleCell.vue_vue_type_script_setup_true_lang.js +19 -18
- package/dist/renderers/IconToggleCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/JsonCell.vue_vue_type_script_setup_true_lang.js +21 -20
- package/dist/renderers/JsonCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/JsonTreeCell.vue_vue_type_script_setup_true_lang.js +21 -20
- package/dist/renderers/JsonTreeCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/ListCell.vue_vue_type_script_setup_true_lang.js +18 -17
- package/dist/renderers/ListCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/MultiLineCell.vue_vue_type_script_setup_true_lang.js +35 -34
- package/dist/renderers/MultiLineCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/parts/CopyButton.vue_vue_type_script_setup_true_lang.js +19 -18
- package/dist/renderers/parts/CopyButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/types/agent/requirements.d.ts +1 -1
- package/dist/types/components/VGrid.vue.d.ts +45 -9
- package/dist/types/components/VGridColumnMenu.vue.d.ts +4 -5
- package/dist/types/components/VGridMenu.vue.d.ts +1 -1
- package/dist/types/components/VGridPagination.vue.d.ts +8 -3
- package/dist/types/components/VGridSearch.vue.d.ts +2 -2
- package/dist/types/composables/useDataSource.d.ts +33 -2
- package/dist/types/composables/useGridExport.d.ts +4 -1
- package/dist/types/composables/useGridMenus.d.ts +3 -1
- package/dist/types/composables/useRowGrouping.d.ts +12 -1
- package/dist/types/composables/useServerGroups.d.ts +37 -0
- package/dist/types/composables/useStatusBar.d.ts +7 -0
- package/dist/types/core/grouping.d.ts +26 -0
- package/dist/types/features/export.d.ts +2 -1
- package/dist/types/features/index.d.ts +2 -1
- package/dist/types/features/serverGrouping.d.ts +9 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/internal/context.d.ts +5 -1
- package/dist/types/internal/features.d.ts +2 -1
- package/dist/types/internal/messages.d.ts +16 -0
- package/dist/types/internal/print.d.ts +16 -0
- package/dist/types/renderers/parts/CopyButton.vue.d.ts +1 -3
- package/dist/types/types.d.ts +305 -1
- package/llms-full.txt +264 -110
- package/llms.txt +1 -1
- package/package.json +1 -1
package/llms-full.txt
CHANGED
|
@@ -45,30 +45,32 @@ runs in the [live examples](https://eboye.github.io/eboye-vue-grid/), each with
|
|
|
45
45
|
|
|
46
46
|
## Which feature for what
|
|
47
47
|
|
|
48
|
-
| The user wants… | Feature(s)
|
|
49
|
-
| ------------------------------------------------- |
|
|
50
|
-
| Click a header to sort | `sortingFeature`
|
|
51
|
-
| Filters per column, a filter row, quick search | `filteringFeature`
|
|
52
|
-
| Pages | `paginationFeature`
|
|
53
|
-
| Backend sorting / filtering / paging | `serverDataFeature` (+ the above)
|
|
54
|
-
| Checkboxes / row selection, batch actions | `selectionFeature`
|
|
55
|
-
| Nested child rows aligned to the parent's columns | `subGridsFeature`
|
|
56
|
-
| An expandable panel under a row | —
|
|
57
|
-
| 10,000+ rows | `virtualScrollingFeature`
|
|
58
|
-
| Right-click menus (cells, headers) | `menusFeature`
|
|
59
|
-
| Freeze columns left / right | `columnPinningFeature`
|
|
60
|
-
| Show / hide columns | `columnVisibilityFeature`
|
|
61
|
-
| Drag columns to reorder | `columnReorderFeature`
|
|
62
|
-
| Drag column edges to resize | `columnResizingFeature`
|
|
63
|
-
| Grouped headers ("Q1" over three columns) | `columnGroupsFeature`
|
|
64
|
-
| Rows that stay on top / bottom | `rowPinningFeature`
|
|
65
|
-
| A totals row (sum, avg, …) | `aggregationFeature`
|
|
66
|
-
| Group
|
|
67
|
-
|
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
|
|
|
48
|
+
| The user wants… | Feature(s) | Props / column options |
|
|
49
|
+
| ------------------------------------------------- | --------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
50
|
+
| Click a header to sort | `sortingFeature` | column `sortable: true`; `sort-mode="client"` (or handle `v-model:sort`) |
|
|
51
|
+
| Filters per column, a filter row, quick search | `filteringFeature` | column `filterable: true` (`filter: 'text' \| 'number' \| 'date' \| 'boolean' \| 'set'`); `filter-row`; `<VGridSearch />` in `#toolbar` |
|
|
52
|
+
| Pages | `paginationFeature` | `pagination` (or `{ pageSizes: [10, 25, 50] }`), `v-model:page`, `v-model:page-size` |
|
|
53
|
+
| Backend sorting / filtering / paging | `serverDataFeature` (+ the above) | `:data-source="(query, { signal }) => Promise<{ rows, total }>"` |
|
|
54
|
+
| Checkboxes / row selection, batch actions | `selectionFeature` | `selectable` (or `'single'`), `v-model:selected`, `is-row-selectable`, `prune-selection`; `#toolbar="{ selected, selectedCount, clearSelection }"`; server data: `v-model:select-all-matching` |
|
|
55
|
+
| Nested child rows aligned to the parent's columns | `subGridsFeature` | `:sub-rows="(row) => row.children"` or `:load-sub-rows` + `:has-sub-rows` |
|
|
56
|
+
| An expandable panel under a row | — | `#detail="{ row }"` slot (`row-expandable` to limit it) |
|
|
57
|
+
| 10,000+ rows | `virtualScrollingFeature` | `:virtual="{ rowHeight: 40 }"` + bounded height |
|
|
58
|
+
| Right-click menus (cells, headers) | `menusFeature` | `:context-menu="(ctx) => MenuItem[]"` + `@context-action`; header menu is on by default |
|
|
59
|
+
| Freeze columns left / right | `columnPinningFeature` | column `pinned: 'left' \| 'right'`; on narrow grids they scroll unless `pinned-max-share` allows (default half the width) |
|
|
60
|
+
| Show / hide columns | `columnVisibilityFeature` | column `hidden: true`; `<VGridColumnMenu>` in `#toolbar` |
|
|
61
|
+
| Drag columns to reorder | `columnReorderFeature` | column `reorderable: false` to lock one |
|
|
62
|
+
| Drag column edges to resize | `columnResizingFeature` | `minWidth` / `maxWidth`, `resizable: false` |
|
|
63
|
+
| Grouped headers ("Q1" over three columns) | `columnGroupsFeature` | column `group: 'Q1'` |
|
|
64
|
+
| Rows that stay on top / bottom | `rowPinningFeature` | `v-model:pinned-rows="{ top: [id], bottom: [] }"`, `pinRow()`, `pinned-top-rows` |
|
|
65
|
+
| A totals row (sum, avg, …) | `aggregationFeature` | column `aggregate: 'sum' \| 'avg' \| 'min' \| 'max' \| 'count' \| fn`; `totals` (or `'top'`) |
|
|
66
|
+
| Group server data across all rows (not the page) | `serverGroupingFeature` (+ `rowGroupingFeature`, `serverDataFeature`) | return `{ groups: [{ value, count, aggregates }], total }` for `query.groupBy` / `query.groupPath`, `{ rows }` at the last level; `v-model:selected-groups` |
|
|
67
|
+
| Group rows by a column ("by status, then city") | `rowGroupingFeature` | `v-model:group-by="['status', 'city']"`, `groups-expanded`; column `groupable: true` (header menu), `groupValue: (row) => …` (e.g. month); `aggregate` shows per group |
|
|
68
|
+
| Download CSV / Excel, print, copy rows / cells | `exportFeature` | `grid.exportCsv()`, `getCsv()`, `exportXlsx()`, `getXlsx()`, `print()`, `copyRows()`, `@copy`; column `exportValue`, `exportable: false` |
|
|
69
|
+
| Row / selection counts, sum of the selected rows | `statusBarFeature` | `status-bar` (or `{ summary: ['total'], aggregates?: ['sum', 'avg'] }`); `#status-bar="{ rowCount, selectedCount, summary, … }"` |
|
|
70
|
+
| Translate / reword the grid, drop built-in pieces | — | `messages` (`GridMessages`), `parts` (`GridParts`): app-wide in `createVueGrid` or per grid; slots `#load-error`, `#no-match`, `#select-all-banner` |
|
|
71
|
+
| Arrow-key navigation (ARIA grid) | `keyboardNavigationFeature` | — |
|
|
72
|
+
| Remember column layout | — | `storage="orders-grid"` (localStorage key) |
|
|
73
|
+
| Cell type (money, date, badge, link, …) | — | `renderer: currencyRenderer` etc. (list below) |
|
|
72
74
|
|
|
73
75
|
## Renderers (pick by data)
|
|
74
76
|
|
|
@@ -400,6 +402,8 @@ raw values; `copyRows` and Ctrl/⌘+C to the selected rows as displayed, tab-sep
|
|
|
400
402
|
`header`, `totals`, `children`, `delimiter`. `toCsv(rows, columns)` works without a grid.
|
|
401
403
|
`exportXlsx({ filename, sheetName })` / `getXlsx()` (a Promise) write an Excel file with typed cells
|
|
402
404
|
(numbers, dates, booleans) and number formats from the renderers; `toXlsx(rows, columns)` without a grid.
|
|
405
|
+
`print({ title, totals, landscape })` prints every matching row as a table (header on each page);
|
|
406
|
+
Ctrl+P on the page only prints what is on screen.
|
|
403
407
|
|
|
404
408
|
### Row actions and context menu
|
|
405
409
|
|
|
@@ -512,6 +516,11 @@ only sees stylesheet rules. Density:
|
|
|
512
516
|
- Ctrl+C copies nothing for a clicked cell → cells only take focus with `keyboardNavigationFeature`
|
|
513
517
|
(or select rows first); `exportFeature` must be registered too.
|
|
514
518
|
- An exported column of `⋯` / buttons / `[object Object]` → `exportable: false`, or `exportValue: (row) => …`.
|
|
519
|
+
- Printing the page (Ctrl+P) shows only the rows on screen, clipped to the grid → use `grid.print()`.
|
|
520
|
+
- Translating by replacing components or CSS `content` → set `messages` (every built-in text has a key).
|
|
521
|
+
- Hiding a built-in piece with CSS → `parts: { filterButtons: false, … }` leaves it out of the DOM (and the tab order).
|
|
522
|
+
- Grouped server data shows groups of one page only → add `serverGroupingFeature` and answer `query.groupBy` with `{ groups }` (`count` per group, `total` = number of groups).
|
|
523
|
+
- A batch action on a selected server group touched only loaded rows → act on `selectedGroups` (paths) with the filters on the server.
|
|
515
524
|
- Copied numbers come out as `€1,234.50` → copying uses displayed values; pass `{ values: 'raw' }`
|
|
516
525
|
(CSV exports are raw by default).
|
|
517
526
|
- `group-by` names a field, not a column → it takes column `key`s; add a (hidden) column for it.
|
|
@@ -522,7 +531,7 @@ only sees stylesheet rules. Density:
|
|
|
522
531
|
|
|
523
532
|
---
|
|
524
533
|
|
|
525
|
-
# @nocopypaste/vue-grid 0.
|
|
534
|
+
# @nocopypaste/vue-grid 0.8.0 — API reference
|
|
526
535
|
|
|
527
536
|
> Generated from the TypeScript sources (`scripts/gen-agent.mjs`). Machine-readable: `agent/api.json`, `agent/grid-config.schema.json`.
|
|
528
537
|
|
|
@@ -538,7 +547,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
|
|
|
538
547
|
| `columnReorderFeature` | Column reordering: drag a header (mouse, pen, touch), Alt+←/→ on a focused header, and the header menu's Move left / Move right. Columns opt out with `reorderable: false`. The order is part of `v-model:column-state` and persisted with `storage`; `<VGridColumnMenu>` works without it. | | `reorderable` |
|
|
539
548
|
| `columnResizingFeature` | Column resizing: drag a header's edge (mouse, pen, touch), use ←/→ on the focused edge (Alt+Shift+←/→ on a header with keyboard navigation), or double-click the edge to fit the content. `minWidth` / `maxWidth` bound it; columns opt out with `resizable: false`. Widths are kept in `columnState.widths` and persisted with `storage`. The header menu gains Fit width / Reset width. | | `maxWidth` `resizable` |
|
|
540
549
|
| `columnVisibilityFeature` | Column visibility: `hidden: true` columns, `columnState.hidden` (persisted with `storage`), the header menu's Hide column item and `<VGridColumnMenu>`'s checkboxes. Columns opt out with `hideable: false`. Without it, every column shows. | | `hidden` `hideable` |
|
|
541
|
-
| `exportFeature` | CSV and Excel export and copying: `grid.exportCsv()` downloads the filtered, sorted rows as a CSV file, `grid.getCsv()` returns the text, `grid.exportXlsx()` / `grid.getXlsx()` write an Excel workbook with typed cells (the writer loads on demand), `grid.copyRows()` copies rows as tab-separated text, and Ctrl/⌘+C copies the selected rows, else the focused cell, as displayed. Columns can set `exportValue` and `exportable: false`. Without it those methods only warn. | | `exportValue` `exportable` |
|
|
550
|
+
| `exportFeature` | CSV and Excel export and copying: `grid.exportCsv()` downloads the filtered, sorted rows as a CSV file, `grid.getCsv()` returns the text, `grid.exportXlsx()` / `grid.getXlsx()` write an Excel workbook with typed cells (the writer loads on demand), `grid.print()` prints every matching row as a table with the header on each page, `grid.copyRows()` copies rows as tab-separated text, and Ctrl/⌘+C copies the selected rows, else the focused cell, as displayed. Columns can set `exportValue` and `exportable: false`. Without it those methods only warn. | | `exportValue` `exportable` |
|
|
542
551
|
| `filteringFeature` | Filtering: header funnels with typed filter popovers on `filterable` columns, the filter row, `<VGridSearch>`, the filter items of the header menu, `v-model:filters` and filter persistence. The popover body and the filter-row editors load on demand (own chunks). | `filterMode` `filterRow` `filterStorage` `noMatchText` `filters` | `filterable` `filter` `filterValue` `filterFn` `filterComponent` `searchable` |
|
|
543
552
|
| `keyboardNavigationFeature` | Keyboard navigation (the ARIA grid pattern): the grid is one tab stop, arrow keys / Home / End / PageUp / PageDown move between cells, Enter activates a cell's control, Space selects a row, →/← expand and collapse, Alt+←/→ move a column, ContextMenu / Shift+F10 open the cell menu. Without it the grid is an ARIA `table`: its own controls (sort buttons, expanders, checkboxes, filter buttons) sit in the normal Tab order instead. | | |
|
|
544
553
|
| `menusFeature` | Context menus: the built-in header menu (sort, filter, pin, move, hide, reset, your own items via `header-menu`) and body-cell menus (`context-menu`), opened by right-click, the ContextMenu key or Shift+F10. Without it the browser's own menu shows. The standalone `<VGridMenu>` and the `actions-menu` renderer don't need it. | `contextMenu` `headerMenu` | |
|
|
@@ -547,6 +556,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
|
|
|
547
556
|
| `rowPinningFeature` | Pinned rows: `v-model:pinned-rows` (`{ top, bottom }` row keys), `pinned-top-rows` / `pinned-bottom-rows` (extra rows that aren't in the data) and the `pinRow()` method. Pinned rows stay in view (sticky) under the header or at the bottom while the body scrolls, and aren't filtered, sorted or paged. Without it, those options are ignored. | `pinnedTopRows` `pinnedBottomRows` `pinnedRows` | |
|
|
548
557
|
| `selectionFeature` | Row selection: the `selectable` prop (multi or single), `v-model:selected`, `selection-mode` (cascade through sub-grids), `is-row-selectable`, Space on a row, shift-click (or Shift+Space) for a range, the select-all checkbox, `prune-selection`, and with server data a "select all N matching rows" banner (`v-model:select-all-matching`; it loads on demand, its own chunk). | `selectable` `selectionMode` `isRowSelectable` `pruneSelection` `selected` `selectAllMatching` | |
|
|
549
558
|
| `serverDataFeature` | Server data: the `dataSource` prop. The grid sends sort, filters and page to your function, cancels superseded requests, and shows loading, error and retry states. | `dataSource` | |
|
|
559
|
+
| `serverGroupingFeature` | Row grouping with server data: with `group-by` and a `data-source`, the query carries `groupBy` and `groupPath`, the server answers with groups (value, count, aggregates), and each group's contents load when it expands. A group's checkbox selects it by query (`v-model:selected-groups`), without loading its rows. Needs the row grouping and server data features too. Without it, a grouped server grid groups only the rows it has loaded. | `selectedGroups` | |
|
|
550
560
|
| `sortingFeature` | Sorting: the sort button on `sortable` column headers, the sort items of the header menu and, with `sort-mode="client"`, sorting the rows in the browser. | | `sortable` `sortValue` `sortFn` |
|
|
551
561
|
| `statusBarFeature` | A status bar under the grid (`status-bar`): how many rows pass the filters ("84 of 200 rows"), how many are selected, how many filters are on (with Clear), and with `{ summary: ['total'] }` the sum and average of those columns over the selected rows, as the cells show them. The `#status-bar` slot replaces its content. Its component loads on demand (own chunk). | `statusBar` | |
|
|
552
562
|
| `subGridsFeature` | Sub-grids: nested child rows in a CSS `subgrid`, from `sub-rows` (synchronous) or `load-sub-rows` (lazy, cached, with loading / error / retry). Detail rows (`#detail` slot) don't need it. | `subRows` `loadSubRows` `hasSubRows` | |
|
|
@@ -561,13 +571,15 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
|
|
|
561
571
|
| `rowKey` (required) | `RowKeyGetter<T>` | | | Stable unique id of a row: a property name or `(row) => string \| number`. All row state is keyed by it. |
|
|
562
572
|
| `features` | `readonly GridFeature[]` | | | Opt-in features for this grid (added to the app-wide `createVueGrid({ features })`): `sortingFeature`, `filteringFeature`, `serverDataFeature`, `paginationFeature`, or `allFeatures`. Read once, when the grid is created. |
|
|
563
573
|
| `dataSource` | `DataSource<T>` | | `serverDataFeature` | Server data: called with the current query (sort, filters, search, page) whenever it changes. The grid cancels superseded requests, shows loading and errors, and sorts / filters / pages nothing itself. |
|
|
564
|
-
| `pagination` | `boolean \|
|
|
574
|
+
| `pagination` | `boolean \| PaginationOptions` | `false` | `paginationFeature` | Built-in pagination under the grid (server-side with `dataSource`, client-side otherwise). |
|
|
565
575
|
| `statusBar` | `boolean \| StatusBarOptions` | | `statusBarFeature` | A status bar under the grid (status bar feature): rows that pass the filters ("84 of 200 rows"), selected rows, active filters with Clear; `{ summary: ['total'] }` adds the sum and average of those columns over the selected rows. `#status-bar` replaces its content. |
|
|
576
|
+
| `messages` | `GridMessages` | | | Built-in text (translations, wording), over `createVueGrid({ messages })`. |
|
|
577
|
+
| `parts` | `GridParts` | | | Built-in parts to leave out (`{ progressBar: false }`), over `createVueGrid({ parts })`. |
|
|
566
578
|
| `sortMode` | `'controlled' \| 'client'` | `'controlled'` | | `controlled` (default): a header click only updates `v-model:sort` (sort on the server or in your own code). `client`: the grid sorts the rows itself. Ignored with `dataSource`. |
|
|
567
579
|
| `filterMode` | `'client' \| 'controlled'` | `'client'` | `filteringFeature` | `client` (default): the grid filters its rows. `controlled`: it only emits `update:filters`. |
|
|
568
580
|
| `filterRow` | `boolean` | `false` | `filteringFeature` | Show the filter row: an input under each filterable column's header. |
|
|
569
581
|
| `filterStorage` | `FilterStateStorage \| string` | | `filteringFeature` | Persist the filter model (`string` = localStorage key). |
|
|
570
|
-
| `noMatchText` | `string` |
|
|
582
|
+
| `noMatchText` | `string` | | `filteringFeature` | Shown when filters hide every row. Default: `messages.noMatch`, else `No rows match the current filters.` |
|
|
571
583
|
| `selectable` | `boolean \| 'single'` | `false` | `selectionFeature` | A selection column: `true` = multi-select (with select-all), `'single'` = one row. |
|
|
572
584
|
| `selectionMode` | `'cascade' \| 'independent'` | `'cascade'` | `selectionFeature` | `cascade` (default): selecting a parent selects its children. `independent`: rows alone. |
|
|
573
585
|
| `isRowSelectable` | `(row: T) => boolean` | | `selectionFeature` | Rows that can't be selected get a disabled checkbox. |
|
|
@@ -589,7 +601,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
|
|
|
589
601
|
| `timeZone` | `string` | | | IANA time zone for date renderers and date filters. |
|
|
590
602
|
| `density` | `Density` | | | Cell padding scale. |
|
|
591
603
|
| `loading` | `boolean` | `false` | | Shows a progress bar and sets `aria-busy` (server data sets it by itself). |
|
|
592
|
-
| `emptyText` | `string` |
|
|
604
|
+
| `emptyText` | `string` | | | Shown when there are no rows. Default: `messages.empty`, else `No data to show.` |
|
|
593
605
|
| `ariaLabel` | `string` | | | Accessible name of the grid. |
|
|
594
606
|
| `ui` | `Partial<Record<GridPart, ClassValue>>` | | | Extra classes per part (`root`, `header`, `headerCell`, `row`, `cell`, `subgrid`, `detail`, `empty`), e.g. Tailwind utilities. |
|
|
595
607
|
| `contextMenu` | `(ctx: CellContext<T>) => MenuItem[] \| null \| undefined` | | `menusFeature` | Right-click menu items for a body cell. Return `null`/`[]` to keep the browser's menu. |
|
|
@@ -597,7 +609,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
|
|
|
597
609
|
| `pinnedTopRows` | `readonly T[]` | | `rowPinningFeature` | Extra rows above the body, not part of the data (row pinning feature). |
|
|
598
610
|
| `pinnedBottomRows` | `readonly T[]` | | `rowPinningFeature` | Extra rows below the body, not part of the data (row pinning feature). |
|
|
599
611
|
| `totals` | `boolean \| 'top' \| 'bottom'` | `false` | `aggregationFeature` | A totals row with each column's `aggregate` (aggregation feature): `true` / `'bottom'` sticks it to the bottom, `'top'` under the header. |
|
|
600
|
-
| `totalsLabel` | `string` |
|
|
612
|
+
| `totalsLabel` | `string` | | `aggregationFeature` | The totals row's label, in its first column (unless that column has an aggregate). Default: `messages.total`, else `Total`. |
|
|
601
613
|
| `aggregates` | `Record<string, unknown>` | | `aggregationFeature` | Totals row values by column key, instead of computing them (e.g. totals from a server). |
|
|
602
614
|
| `groupsExpanded` | `boolean` | `false` | `rowGroupingFeature` | Groups start expanded (row grouping feature). Default: collapsed. |
|
|
603
615
|
|
|
@@ -615,6 +627,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
|
|
|
615
627
|
| `v-model:pinnedRows` | `PinnedRowsState \| null` | `null` | `rowPinningFeature` | Top-level rows pinned above / below the body, by key: `{ top, bottom }`. Needs the row pinning feature. |
|
|
616
628
|
| `v-model:groupBy` | `readonly string[] \| string \| null` | `null` | `rowGroupingFeature` | Column keys to group the rows by, outermost first (`['region', 'status']`, or one key). Group rows show the value, the row count and the columns' aggregates. Needs the row grouping feature. |
|
|
617
629
|
| `v-model:selectAllMatching` | `boolean` | `false` | `selectionFeature` | Server data: every row matching the query is selected, not just the loaded ones (set from the "Select all N rows" banner; ends when filters change or a row is unticked). Act on the query then, not on `selected`. Needs the selection feature. |
|
|
630
|
+
| `v-model:selectedGroups` | `GroupPath[]` | `[]` | `serverGroupingFeature` | Server data with row grouping: groups selected by query, by their paths, without loading their rows (a group's checkbox). Act on these with `selected` and the filters. Ends when the filters or the grouping change. Needs the selection and row grouping features. |
|
|
618
631
|
|
|
619
632
|
## Events
|
|
620
633
|
|
|
@@ -640,10 +653,13 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
|
|
|
640
653
|
| `group-<key>` | `{ value: unknown; count: number; rows: readonly T[]; column: ColumnDef<T>; group: RowGroup<T> }` | The value of a group row grouped by this column (row grouping feature): `#group-<key>`. |
|
|
641
654
|
| `detail` | `{ row: T; rowKey: RowKey; depth: number }` | Expandable detail row under a row: any content, even another grid. |
|
|
642
655
|
| `empty` | | Shown when there are no rows. |
|
|
656
|
+
| `no-match` | `{ clearFilters: () => void; filterCount: number }` | Shown when filters hide every row, instead of the message and its Clear filters button. |
|
|
657
|
+
| `load-error` | `{ error: unknown; retry: () => Promise<void>; stale: boolean }` | A failed server request (server data): `stale` when the rows from before stay on screen (the notice above them), else in place of the rows. `retry()` asks again. |
|
|
658
|
+
| `select-all-banner` | `{ total: number; page: number; all: boolean; selectAll: () => void; clearSelection: () => void }` | Selection with server data: the "Select all N rows" banner. |
|
|
643
659
|
| `status-bar` | `StatusBarScope` | The status bar's content (status bar feature): replaces the counts and the summary. |
|
|
644
660
|
| `loading` | | Shown while loading with no rows yet. |
|
|
645
661
|
| `sub-rows-loading` | `{ row: T }` | Shown while a row's lazy children load. |
|
|
646
|
-
| `toolbar` | `{ columns: readonly ColumnDef<T>[]; columnState: ColumnState; setColumnState: (state: ColumnState) => void; filters: FilterState; setFilters: (state: FilterState) => void; clearFilters: () => void; activeFilterCount: number; selected: readonly RowKey[]; selectedCount: number; selectAllMatching: boolean; clearSelection: () => void }` | Above the grid: put a search box, column menu, filter summary or batch actions here. |
|
|
662
|
+
| `toolbar` | `{ columns: readonly ColumnDef<T>[]; columnState: ColumnState; setColumnState: (state: ColumnState) => void; filters: FilterState; setFilters: (state: FilterState) => void; clearFilters: () => void; activeFilterCount: number; selected: readonly RowKey[]; selectedCount: number; selectedGroups: GroupPath[]; selectAllMatching: boolean; clearSelection: () => void }` | Above the grid: put a search box, column menu, filter summary or batch actions here. |
|
|
647
663
|
|
|
648
664
|
## Exposed methods (`ref<VGridExposed>()`)
|
|
649
665
|
|
|
@@ -666,6 +682,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
|
|
|
666
682
|
| `exportCsv` | `void` | | Downloads the rows as a CSV file (`filename`, default `export.csv`; UTF-8 with a BOM). Export feature. |
|
|
667
683
|
| `getXlsx` | `Promise<Blob>` | | The rows as an Excel workbook (.xlsx): typed cells (numbers, dates, booleans), number formats from the columns' renderers, a bold frozen header. The writer loads on demand. Export feature. |
|
|
668
684
|
| `exportXlsx` | `Promise<void>` | | Downloads the rows as an Excel file (`filename`, default `export.xlsx`). Export feature. |
|
|
685
|
+
| `print` | `Promise<void>` | | Prints the rows as a table (the browser's print dialog): the filtered, sorted rows on every page (not just those in view), as the cells show them, the header repeated on each printed page, numbers right-aligned, the totals in bold. Resolves when printing is over. Export feature. |
|
|
669
686
|
| `copyRows` | `Promise<boolean>` | | Copies rows to the clipboard as tab-separated text (pastes as cells into spreadsheets): the selected rows by default, as displayed, no header. Resolves `false` if nothing was copied. Export feature. |
|
|
670
687
|
|
|
671
688
|
## `ColumnDef<T>`
|
|
@@ -1175,6 +1192,8 @@ The first items of a list, with a “+N more” toggle. Emits `expand`. Align: `
|
|
|
1175
1192
|
| `currency`? | `string` | Default ISO 4217 currency for currency renderers. |
|
|
1176
1193
|
| `timeZone`? | `string` | Default IANA time zone for date renderers and date filters. |
|
|
1177
1194
|
| `density`? | `Density` | Default density: `compact`, `cozy` (default) or `comfortable`. |
|
|
1195
|
+
| `messages`? | `GridMessages` | Built-in text for every grid (translations, wording); a grid's own `messages` win. |
|
|
1196
|
+
| `parts`? | `GridParts` | Built-in parts to turn off in every grid; a grid's own `parts` win. |
|
|
1178
1197
|
|
|
1179
1198
|
---
|
|
1180
1199
|
|
|
@@ -1182,6 +1201,8 @@ The first items of a list, with a “+N more” toggle. Emits `expand`. Align: `
|
|
|
1182
1201
|
|
|
1183
1202
|
# @nocopypaste/vue-grid
|
|
1184
1203
|
|
|
1204
|
+
[](https://eboye.github.io/eboye-vue-grid/) — every feature running live, with its source.
|
|
1205
|
+
|
|
1185
1206
|
A data grid for Vue 3 built on **CSS Grid** — with real `subgrid` sub-rows, pinned columns, column
|
|
1186
1207
|
reorder/visibility with persistence, selection, virtual scrolling, pagination, a pluggable
|
|
1187
1208
|
**cell-renderer registry** for 3rd-party addons, and a theme you customise with **CSS variables**.
|
|
@@ -1312,7 +1333,8 @@ an opt-in feature:
|
|
|
1312
1333
|
| `rowPinningFeature` | `v-model:pinned-rows` / `pinRow()`: rows that stay in view above or below the body, plus `pinned-top-rows` / `pinned-bottom-rows` for rows that aren't in the data |
|
|
1313
1334
|
| `aggregationFeature` | Column `aggregate` (`sum`, `avg`, `min`, `max`, `count`, a function) and `totals`: a sticky totals row over the filtered rows |
|
|
1314
1335
|
| `rowGroupingFeature` | `v-model:group-by`: rows grouped by one or more columns into collapsible group rows with the value, row count and aggregates; Group by / Ungroup in the header menu for `groupable` columns |
|
|
1315
|
-
| `
|
|
1336
|
+
| `serverGroupingFeature` | With a `data-source`: groups from the server (`query.groupBy` / `groupPath`), each one's contents loaded on expand, groups selected by query (`v-model:selected-groups`). See [Server-side grouping](#server-side-grouping) |
|
|
1337
|
+
| `exportFeature` | `exportCsv()` / `getCsv()`, `exportXlsx()` / `getXlsx()` (Excel, typed cells), `print()` (every row, header on each page), `copyRows()`, Ctrl/⌘+C for the selected rows or the focused cell, the `copy` event; column `exportValue` / `exportable` |
|
|
1316
1338
|
| `statusBarFeature` | `status-bar`: a bar under the grid with the rows that pass the filters, the selected rows, the active filters (with Clear), and `{ summary: [keys] }` columns' sum and average over the selected rows; the `#status-bar` slot |
|
|
1317
1339
|
|
|
1318
1340
|
```ts
|
|
@@ -1357,33 +1379,34 @@ what you import.
|
|
|
1357
1379
|
|
|
1358
1380
|
| Import (minified / gzip, Vue excluded) | Initial chunk |
|
|
1359
1381
|
| ---------------------------------------------------------------------------- | ------------------ |
|
|
1360
|
-
| `VGrid` (no features) |
|
|
1361
|
-
| `VGrid` + `sortingFeature` |
|
|
1362
|
-
| `VGrid` + `filteringFeature` |
|
|
1363
|
-
| `VGrid` + `serverDataFeature` |
|
|
1364
|
-
| `VGrid` + `paginationFeature` |
|
|
1365
|
-
| `VGrid` + `selectionFeature` |
|
|
1366
|
-
| `VGrid` + `subGridsFeature` |
|
|
1367
|
-
| `VGrid` + `menusFeature` |
|
|
1368
|
-
| `VGrid` + `columnReorderFeature` |
|
|
1369
|
-
| `VGrid` + `columnPinningFeature` |
|
|
1370
|
-
| `VGrid` + `virtualScrollingFeature` |
|
|
1371
|
-
| `VGrid` + `columnVisibilityFeature` |
|
|
1372
|
-
| `VGrid` + `keyboardNavigationFeature` |
|
|
1373
|
-
| `VGrid` + `columnResizingFeature` |
|
|
1374
|
-
| `VGrid` + `columnGroupsFeature` |
|
|
1375
|
-
| `VGrid` + `rowPinningFeature` |
|
|
1376
|
-
| `VGrid` + `aggregationFeature` |
|
|
1377
|
-
| `VGrid` + `rowGroupingFeature` |
|
|
1378
|
-
| `VGrid` + `exportFeature` |
|
|
1379
|
-
| `VGrid` + `statusBarFeature` |
|
|
1380
|
-
| `VGrid` + `
|
|
1381
|
-
| `VGrid` + `
|
|
1382
|
-
| `VGrid` + `
|
|
1382
|
+
| `VGrid` (no features) | 43.1 kB / 14.8 kB |
|
|
1383
|
+
| `VGrid` + `sortingFeature` | 43.8 kB / 15.1 kB |
|
|
1384
|
+
| `VGrid` + `filteringFeature` | 53.8 kB / 18.6 kB |
|
|
1385
|
+
| `VGrid` + `serverDataFeature` | 44.5 kB / 15.4 kB |
|
|
1386
|
+
| `VGrid` + `paginationFeature` | 43.2 kB / 14.8 kB |
|
|
1387
|
+
| `VGrid` + `selectionFeature` | 47.2 kB / 16.2 kB |
|
|
1388
|
+
| `VGrid` + `subGridsFeature` | 45.4 kB / 15.6 kB |
|
|
1389
|
+
| `VGrid` + `menusFeature` | 53.9 kB / 18.4 kB |
|
|
1390
|
+
| `VGrid` + `columnReorderFeature` | 46.7 kB / 16.0 kB |
|
|
1391
|
+
| `VGrid` + `columnPinningFeature` | 46.0 kB / 15.8 kB |
|
|
1392
|
+
| `VGrid` + `virtualScrollingFeature` | 48.8 kB / 17.0 kB |
|
|
1393
|
+
| `VGrid` + `columnVisibilityFeature` | 43.2 kB / 14.8 kB |
|
|
1394
|
+
| `VGrid` + `keyboardNavigationFeature` | 45.8 kB / 15.8 kB |
|
|
1395
|
+
| `VGrid` + `columnResizingFeature` | 46.3 kB / 16.0 kB |
|
|
1396
|
+
| `VGrid` + `columnGroupsFeature` | 44.4 kB / 15.2 kB |
|
|
1397
|
+
| `VGrid` + `rowPinningFeature` | 48.0 kB / 16.1 kB |
|
|
1398
|
+
| `VGrid` + `aggregationFeature` | 48.2 kB / 16.2 kB |
|
|
1399
|
+
| `VGrid` + `rowGroupingFeature` | 53.8 kB / 18.3 kB |
|
|
1400
|
+
| `VGrid` + `exportFeature` | 48.0 kB / 16.7 kB |
|
|
1401
|
+
| `VGrid` + `statusBarFeature` | 45.5 kB / 15.7 kB |
|
|
1402
|
+
| `VGrid` + `serverGroupingFeature` | 46.2 kB / 15.9 kB |
|
|
1403
|
+
| `VGrid` + `allFeatures` + `VGridSearch` | 115.0 kB / 38.6 kB |
|
|
1404
|
+
| `VGrid` + `currencyRenderer` | 44.4 kB / 15.2 kB |
|
|
1405
|
+
| `VGrid` + `VGridPagination` + `VGridColumnMenu` | 50.3 kB / 17.2 kB |
|
|
1383
1406
|
| `sortRows` only | 0.7 kB / 0.4 kB |
|
|
1384
1407
|
| `toCsv` only | 1.1 kB / 0.6 kB |
|
|
1385
|
-
| everything |
|
|
1386
|
-
| `validateGridConfig` (`@nocopypaste/vue-grid/agent`, never in an app bundle) |
|
|
1408
|
+
| everything | 168.7 kB / 54.0 kB |
|
|
1409
|
+
| `validateGridConfig` (`@nocopypaste/vue-grid/agent`, never in an app bundle) | 72.9 kB / 19.8 kB |
|
|
1387
1410
|
|
|
1388
1411
|
With `filteringFeature`, the filter popover body and the filter-row editors are **on-demand
|
|
1389
1412
|
chunks**: they load the first time a popover opens or `filter-row` is on. With
|
|
@@ -1400,57 +1423,61 @@ chunks that on-demand imports share with the entry, even when nothing uses them.
|
|
|
1400
1423
|
|
|
1401
1424
|
### Props
|
|
1402
1425
|
|
|
1403
|
-
| Prop | Type | Default
|
|
1404
|
-
| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
1405
|
-
| `rows` | `T[]` | `[]`
|
|
1406
|
-
| `features` | `GridFeature[]` | —
|
|
1407
|
-
| `dataSource` | `(query, { signal }) => Promise<{ rows, total? }>` | —
|
|
1408
|
-
| `columns` | `ColumnDef<T>[]` | —
|
|
1409
|
-
| `rowKey` | `keyof T \| (row) => string \| number` | —
|
|
1410
|
-
| `v-model:sort` | `{ key, dir: 'asc' \| 'desc' } \| null` | `null`
|
|
1411
|
-
| `sortMode` | `'controlled' \| 'client'` | `'controlled'`
|
|
1412
|
-
| `v-model:filters` | `FilterState \| null` | `null`
|
|
1413
|
-
| `filterMode` | `'client' \| 'controlled'` | `'client'`
|
|
1414
|
-
| `filterRow` | `boolean` | `false`
|
|
1415
|
-
| `filterStorage` | `string \| FilterStateStorage` | —
|
|
1416
|
-
| `noMatchText` | `string` | `
|
|
1417
|
-
| `pagination` | `boolean \|
|
|
1418
|
-
| `v-model:page` / `v-model:pageSize` | `number` | `1` / `25`
|
|
1419
|
-
| `v-model:columnState` | `{ order: string[]; hidden: string[]; pinned?: Record<string, "left" \| "right" \| null>; widths?: Record<string, string> }` | derived
|
|
1420
|
-
| `storage` | `string \| ColumnStateStorage` | —
|
|
1421
|
-
| `pinnedMaxShare` | `number \| false` | `0.5`
|
|
1422
|
-
| `v-model:expanded` | `RowKey[]` | `[]`
|
|
1423
|
-
| `subRows` | `(row) => T[] \| undefined` | —
|
|
1424
|
-
| `loadSubRows` | `(row) => Promise<T[]>` | —
|
|
1425
|
-
| `hasSubRows` | `(row) => boolean` | —
|
|
1426
|
-
| `rowExpandable` | `(row) => boolean` | —
|
|
1427
|
-
| `selectable` | `boolean \| 'single'` | `false`
|
|
1428
|
-
| `v-model:selected` | `RowKey[]` | `[]`
|
|
1429
|
-
| `selectionMode` | `'cascade' \| 'independent'` | `'cascade'`
|
|
1430
|
-
| `isRowSelectable` | `(row) => boolean` | —
|
|
1431
|
-
| `pruneSelection` | `boolean` | `false`
|
|
1432
|
-
| `v-model:selectAllMatching` | `boolean` | `false`
|
|
1433
|
-
| `virtual` | `{ rowHeight: number; overscan?: number; detailHeight?: number } \| false` | `false`
|
|
1434
|
-
| `v-model:pinnedRows` | `{ top?: RowKey[]; bottom?: RowKey[] } \| null` | `null`
|
|
1435
|
-
| `pinnedTopRows` / `pinnedBottomRows` | `T[]` | —
|
|
1436
|
-
| `totals` | `boolean \| 'top' \| 'bottom'` | `false`
|
|
1437
|
-
| `totalsLabel` | `string` | `
|
|
1438
|
-
| `aggregates` | `Record<string, unknown>` | —
|
|
1439
|
-
| `v-model:groupBy` | `string[] \| string \| null` | `null`
|
|
1440
|
-
| `groupsExpanded` | `boolean` | `false`
|
|
1441
|
-
| `
|
|
1442
|
-
| `
|
|
1443
|
-
| `
|
|
1444
|
-
| `
|
|
1445
|
-
| `
|
|
1446
|
-
| `
|
|
1447
|
-
| `
|
|
1448
|
-
| `
|
|
1449
|
-
| `
|
|
1450
|
-
| `
|
|
1451
|
-
| `
|
|
1452
|
-
| `
|
|
1453
|
-
| `
|
|
1426
|
+
| Prop | Type | Default | |
|
|
1427
|
+
| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1428
|
+
| `rows` | `T[]` | `[]` | Your data objects, used as-is (never mutated). Not needed with `dataSource`. |
|
|
1429
|
+
| `features` | `GridFeature[]` | — | Opt-in features for this grid, added to the app-wide ones. See [Features](#features-everything-optional). |
|
|
1430
|
+
| `dataSource` | `(query, { signal }) => Promise<{ rows, total? }>` | — | Server rows: the grid calls it whenever sort, filters or page change. Needs `serverDataFeature`. See [Server data](#server-data). |
|
|
1431
|
+
| `columns` | `ColumnDef<T>[]` | — | See below. |
|
|
1432
|
+
| `rowKey` | `keyof T \| (row) => string \| number` | — | Stable unique id; all row state is keyed by it. |
|
|
1433
|
+
| `v-model:sort` | `{ key, dir: 'asc' \| 'desc' } \| null` | `null` | Header click cycles asc → desc → none. Needs `sortingFeature` for the header UI. |
|
|
1434
|
+
| `sortMode` | `'controlled' \| 'client'` | `'controlled'` | `controlled` only emits (server-side sorting). Ignored with `dataSource`. |
|
|
1435
|
+
| `v-model:filters` | `FilterState \| null` | `null` | `{ columns: Record<key, ColumnFilter>, search }`. Needs `filteringFeature` (as do the next four). See [Filtering](#filtering). |
|
|
1436
|
+
| `filterMode` | `'client' \| 'controlled'` | `'client'` | `controlled` only emits (server-side filtering). Ignored with `dataSource`. |
|
|
1437
|
+
| `filterRow` | `boolean` | `false` | A row of inline filter inputs under the headers. |
|
|
1438
|
+
| `filterStorage` | `string \| FilterStateStorage` | — | Persist filters (`string` = localStorage key). |
|
|
1439
|
+
| `noMatchText` | `string` | `messages.noMatch` | Shown, with a _Clear filters_ button, when filters hide every row (`No rows match the current filters.`). |
|
|
1440
|
+
| `pagination` | `boolean \| PaginationOptions` | `false` | The built-in pager (pagination feature): `{ pageSizes, siblings, summary, firstLast }`. |
|
|
1441
|
+
| `v-model:page` / `v-model:pageSize` | `number` | `1` / `25` | Reset to page 1 when sort or filters change. |
|
|
1442
|
+
| `v-model:columnState` | `{ order: string[]; hidden: string[]; pinned?: Record<string, "left" \| "right" \| null>; widths?: Record<string, string> }` | derived | Column order, visibility and runtime pins. |
|
|
1443
|
+
| `storage` | `string \| ColumnStateStorage` | — | Persist column state (`string` = localStorage key). |
|
|
1444
|
+
| `pinnedMaxShare` | `number \| false` | `0.5` | Pinned columns scroll like the others while together they'd take more than this share of the grid's width (a phone, a narrow panel), and pin again once there's room. `false`: always pinned. Needs `columnPinningFeature`. |
|
|
1445
|
+
| `v-model:expanded` | `RowKey[]` | `[]` | Expanded rows (sub-grids and detail rows). |
|
|
1446
|
+
| `subRows` | `(row) => T[] \| undefined` | — | Synchronous children → sub-grid. Needs `subGridsFeature` (as do the next two). |
|
|
1447
|
+
| `loadSubRows` | `(row) => Promise<T[]>` | — | Lazy children (cached, loading/error/retry). |
|
|
1448
|
+
| `hasSubRows` | `(row) => boolean` | — | Which rows get an expander when lazy. |
|
|
1449
|
+
| `rowExpandable` | `(row) => boolean` | — | Which rows can open the `#detail` slot. |
|
|
1450
|
+
| `selectable` | `boolean \| 'single'` | `false` | Adds a selection column. Needs `selectionFeature` (as do the next five). See [Selection and batch actions](#selection-and-batch-actions). |
|
|
1451
|
+
| `v-model:selected` | `RowKey[]` | `[]` | |
|
|
1452
|
+
| `selectionMode` | `'cascade' \| 'independent'` | `'cascade'` | Whether selecting a parent selects its children. |
|
|
1453
|
+
| `isRowSelectable` | `(row) => boolean` | — | |
|
|
1454
|
+
| `pruneSelection` | `boolean` | `false` | Drop selected keys whose rows left the data (reload, delete, another server page). |
|
|
1455
|
+
| `v-model:selectAllMatching` | `boolean` | `false` | Server data: every row matching the query is selected (from the banner). |
|
|
1456
|
+
| `virtual` | `{ rowHeight: number; overscan?: number; detailHeight?: number } \| false` | `false` | Virtual scrolling (fixed-height rows; sub-grids and measured detail rows included). Needs `virtualScrollingFeature`. |
|
|
1457
|
+
| `v-model:pinnedRows` | `{ top?: RowKey[]; bottom?: RowKey[] } \| null` | `null` | Top-level rows pinned above / below the body. Needs `rowPinningFeature` (as do the next two). See [Pinned rows and totals](#pinned-rows-and-totals). |
|
|
1458
|
+
| `pinnedTopRows` / `pinnedBottomRows` | `T[]` | — | Extra pinned rows that aren't part of `rows` (a target, last year's figures). |
|
|
1459
|
+
| `totals` | `boolean \| 'top' \| 'bottom'` | `false` | A totals row with each column's `aggregate`; `true` = `'bottom'`. Needs `aggregationFeature` (as do the next two). |
|
|
1460
|
+
| `totalsLabel` | `string` | `messages.total` | Shown in the totals row's first column (unless that column has an aggregate). `Total` by default. |
|
|
1461
|
+
| `aggregates` | `Record<string, unknown>` | — | Totals by column key, used instead of computing them (e.g. from a server). |
|
|
1462
|
+
| `v-model:groupBy` | `string[] \| string \| null` | `null` | Column keys to group the rows by, outermost first. Needs `rowGroupingFeature` (as does the next one). See [Row grouping](#row-grouping). |
|
|
1463
|
+
| `groupsExpanded` | `boolean` | `false` | Groups start expanded. |
|
|
1464
|
+
| `v-model:selectedGroups` | `GroupPath[]` | `[]` | Server-side grouping: groups selected by query, by path (`[[{ key, value }]]`), without their rows. |
|
|
1465
|
+
| `rowClickable` | `boolean` | `false` | Pointer cursor; `row-click` is always emitted. |
|
|
1466
|
+
| `rowClass` | `(row, index) => ClassValue` | — | |
|
|
1467
|
+
| `highlightedRows` | `RowKey[]` | — | |
|
|
1468
|
+
| `flash` | `boolean \| 'direction'` | `false` | Briefly highlight cells whose value changes; `'direction'` = green up / red down. Columns override with `flash`. |
|
|
1469
|
+
| `renderers` | `CellRendererDefinition[]` | — | Renderers usable by name in this grid (override plugin ones). |
|
|
1470
|
+
| `locale` / `currency` / `timeZone` | `string` | plugin → browser | Formatting context for renderers. |
|
|
1471
|
+
| `density` | `'compact' \| 'cozy' \| 'comfortable'` | `'cozy'` | Scales cell padding. |
|
|
1472
|
+
| `loading` | `boolean` | `false` | Progress bar + `aria-busy`. |
|
|
1473
|
+
| `emptyText` | `string` | `messages.empty` | Shown when there are no rows (`No data to show.`). |
|
|
1474
|
+
| `ariaLabel` | `string` | — | |
|
|
1475
|
+
| `statusBar` | `boolean \| StatusBarOptions` | `false` | A status bar under the grid (status bar feature): counts, and `{ summary: [keys] }` sums of the selected rows. See [Status bar](#status-bar). |
|
|
1476
|
+
| `messages` | `GridMessages` | — | Built-in text (translations, wording), over `createVueGrid({ messages })`. See [Text and parts](#text-and-parts). |
|
|
1477
|
+
| `parts` | `GridParts` | — | Built-in parts to leave out (`{ filterButtons: false }`), over `createVueGrid({ parts })`. |
|
|
1478
|
+
| `contextMenu` | `(ctx: { row, rowKey, column, value }) => MenuItem[] \| null` | — | Right-click menu for body cells. Needs `menusFeature`. |
|
|
1479
|
+
| `headerMenu` | `boolean \| ({ column, items }) => MenuItem[] \| null` | `true` | Built-in header menu (sort, pin, move, hide, reset). Needs `menusFeature`. |
|
|
1480
|
+
| `ui` | `Partial<Record<'root' \| 'header' \| 'headerCell' \| 'row' \| 'cell' \| 'subgrid' \| 'detail' \| 'empty', ClassValue>>` | — | Extra classes per part (Tailwind-friendly). |
|
|
1454
1481
|
|
|
1455
1482
|
### Events
|
|
1456
1483
|
|
|
@@ -1469,7 +1496,9 @@ Clicks on links, buttons and inputs inside a cell never trigger `row-click`.
|
|
|
1469
1496
|
`total-<key>` (`{ value, column, group? }`, a cell of the totals row or a group row) ·
|
|
1470
1497
|
`group-<key>` (`{ value, count, rows, column, group }`, the value of a group row) · `detail` (`{ row, rowKey, depth }`) ·
|
|
1471
1498
|
`toolbar` (`{ columns, columnState, setColumnState, filters, setFilters, clearFilters, activeFilterCount, selected, selectedCount, selectAllMatching, clearSelection }`) ·
|
|
1472
|
-
`empty` · `loading` · `sub-rows-loading` (`{ row }`)
|
|
1499
|
+
`empty` · `loading` · `sub-rows-loading` (`{ row }`) · `no-match` (`{ clearFilters, filterCount }`) ·
|
|
1500
|
+
`load-error` (`{ error, retry, stale }`, server data) · `select-all-banner` (`{ total, page, all, selectAll, clearSelection }`) ·
|
|
1501
|
+
`status-bar` (`StatusBarScope`).
|
|
1473
1502
|
|
|
1474
1503
|
### Exposed methods
|
|
1475
1504
|
|
|
@@ -2043,9 +2072,66 @@ Style group rows with `.vg-rowgroup` (and `[data-group-level]`), `.vg-rowgroup-n
|
|
|
2043
2072
|
`--vg-rowgroup-font-weight` tokens. `groupRows()` and `isRowGroup()` are exported for using the
|
|
2044
2073
|
same grouping elsewhere.
|
|
2045
2074
|
|
|
2075
|
+
### Server-side grouping
|
|
2076
|
+
|
|
2077
|
+
With a `data-source`, `serverGroupingFeature` groups across all the data on the server instead of
|
|
2078
|
+
only the rows the grid has loaded. The query then carries `groupBy` and `groupPath`, and your source
|
|
2079
|
+
answers with **groups** instead of rows:
|
|
2080
|
+
|
|
2081
|
+
```ts
|
|
2082
|
+
const source: DataSource<Bet> = async (query, { signal }) => {
|
|
2083
|
+
const res = await fetch('/api/bets/search', {
|
|
2084
|
+
method: 'POST',
|
|
2085
|
+
body: JSON.stringify(query),
|
|
2086
|
+
signal,
|
|
2087
|
+
})
|
|
2088
|
+
return res.json()
|
|
2089
|
+
}
|
|
2090
|
+
// query.groupBy = ['status', 'city'], query.groupPath = [] → the top-level groups
|
|
2091
|
+
// { groups: [{ value: 'Won', count: 1204, aggregates: { stake: 98211.5 } }, …], total: 4 }
|
|
2092
|
+
// query.groupPath = [{ key: 'status', value: 'Won' }] → the groups inside "Won"
|
|
2093
|
+
// { groups: [{ value: 'Niš', count: 310, aggregates: { … } }, …] }
|
|
2094
|
+
// query.groupPath = [{ key: 'status', value: 'Won' }, { key: 'city', value: 'Niš' }]
|
|
2095
|
+
// → the last level: { rows: [ …310 rows… ] }
|
|
2096
|
+
```
|
|
2097
|
+
|
|
2098
|
+
```vue
|
|
2099
|
+
<VGrid
|
|
2100
|
+
v-model:group-by="groupBy"
|
|
2101
|
+
v-model:selected="selected"
|
|
2102
|
+
v-model:selected-groups="selectedGroups"
|
|
2103
|
+
:data-source="source"
|
|
2104
|
+
:columns="columns"
|
|
2105
|
+
row-key="id"
|
|
2106
|
+
selectable
|
|
2107
|
+
:features="[serverDataFeature, rowGroupingFeature, serverGroupingFeature, selectionFeature]"
|
|
2108
|
+
/>
|
|
2109
|
+
```
|
|
2110
|
+
|
|
2111
|
+
- **Lazy.** The first request returns only the top-level groups (`value`, `count`, `aggregates`).
|
|
2112
|
+
Expanding a group asks for its sub-groups, or at the last level all its rows; a level loads
|
|
2113
|
+
once, with a loading row meanwhile and the error and Retry of lazy sub-grids when it fails
|
|
2114
|
+
(`load-error` fires). Requests for a group carry the current sort and filters, `page: 1`,
|
|
2115
|
+
`pageSize: null`.
|
|
2116
|
+
- **Paging.** `pagination` pages the top-level groups: return their number as `total`. Return
|
|
2117
|
+
`rowTotal` (every matching row) for the status bar; without it the groups' counts are added up.
|
|
2118
|
+
- **Sort, filters, page.** A new query asks for the top-level groups again; open groups load their
|
|
2119
|
+
contents again.
|
|
2120
|
+
- **Selection by query.** A group's checkbox selects it by its path in `v-model:selected-groups`
|
|
2121
|
+
(`[[{ key: 'status', value: 'Won' }]]`), without loading its rows; rows and sub-groups inside a
|
|
2122
|
+
selected group show ticked and locked. The header checkbox selects every top-level group. Act on
|
|
2123
|
+
`selectedGroups` + `selected` + the filters on the server. The selected groups end when the
|
|
2124
|
+
filters or the grouping change, or with `clearSelection()`; the status bar and the toolbar's
|
|
2125
|
+
`selectedCount` add their counts.
|
|
2126
|
+
- **Export, print, totals.** `exportCsv()`, `print()` and the others cover the rows that are loaded.
|
|
2127
|
+
For the totals row pass `aggregates` (the server's totals).
|
|
2128
|
+
- Without the feature, a grouped grid with a data source groups only the rows it has loaded (with
|
|
2129
|
+
a dev warning). A source that returns `rows` to a grouped query gets the same.
|
|
2130
|
+
|
|
2046
2131
|
## Export and copy
|
|
2047
2132
|
|
|
2048
|
-
`exportFeature` turns the grid's rows into CSV or an Excel workbook and copies them to
|
|
2133
|
+
`exportFeature` turns the grid's rows into CSV or an Excel workbook, prints them, and copies them to
|
|
2134
|
+
the clipboard.
|
|
2049
2135
|
|
|
2050
2136
|
```vue
|
|
2051
2137
|
<script setup lang="ts">
|
|
@@ -2126,6 +2212,23 @@ Without the grid: `toXlsx(rows, columns, { sheetName, header, timeZone, formats
|
|
|
2126
2212
|
file's bytes (`Uint8Array`); `formats` overrides the guess per column key (`'money'`, `'percent'`,
|
|
2127
2213
|
`'date'`, `'datetime'`, `'number'`, `'auto'`).
|
|
2128
2214
|
|
|
2215
|
+
### Print
|
|
2216
|
+
|
|
2217
|
+
**`print(options)`** prints the rows as a table from a hidden frame, with the browser's print
|
|
2218
|
+
dialog: every row that passes the filters (not just the ones a virtual grid has in view), sorted,
|
|
2219
|
+
as the cells show them. Printing the page itself (Ctrl+P) gives only what is on screen, clipped
|
|
2220
|
+
to the grid's frame.
|
|
2221
|
+
|
|
2222
|
+
```ts
|
|
2223
|
+
await grid.value?.print({ title: 'Orders', totals: true, landscape: true })
|
|
2224
|
+
```
|
|
2225
|
+
|
|
2226
|
+
- A real `<table>`: the header repeats on every printed page, numbers and money are
|
|
2227
|
+
right-aligned as in the grid, the totals print once, in bold, after the last row.
|
|
2228
|
+
- Options: `rows`, `children`, `columns`, `header`, `totals` as for the exports, plus `title`
|
|
2229
|
+
(a heading, also the document title) and `landscape`.
|
|
2230
|
+
- It resolves when printing is over. The printing code (1.1 kB gzip) loads on first use.
|
|
2231
|
+
|
|
2129
2232
|
## Status bar
|
|
2130
2233
|
|
|
2131
2234
|
`statusBarFeature` adds a bar under the grid, like a spreadsheet's:
|
|
@@ -2152,6 +2255,7 @@ file's bytes (`Uint8Array`); `formats` overrides the guess per column key (`'mon
|
|
|
2152
2255
|
(server data) the summary hides: only the loaded page is known.
|
|
2153
2256
|
- **Your own content**: the `#status-bar` slot gets `{ rowCount, totalRowCount, selectedCount,
|
|
2154
2257
|
allSelected, filterCount, summary, clearFilters }` and replaces the default content.
|
|
2258
|
+
- Leave items out with `rows: false`, `selected: false`, `filters: false` or `clear: false`.
|
|
2155
2259
|
- The bar is a `group` labelled "Grid status"; style it with `.vg-status-bar`. Its component loads
|
|
2156
2260
|
on demand (own chunk).
|
|
2157
2261
|
|
|
@@ -2362,6 +2466,56 @@ with `rendererOptions`). Emit `action(name, payload)`; the grid re-emits it as `
|
|
|
2362
2466
|
row and column. `useGridContext()` gives `{ locale, currency, timeZone }`. Lookup order:
|
|
2363
2467
|
a definition or component on the column → `:renderers` → plugin → `text` (the only renderer built in).
|
|
2364
2468
|
|
|
2469
|
+
## Text and parts
|
|
2470
|
+
|
|
2471
|
+
Everything a feature adds is configurable: its text, and whether each piece shows at all.
|
|
2472
|
+
|
|
2473
|
+
**Text.** Every built-in string (menus, filters, the pager, the status bar, notices, screen-reader
|
|
2474
|
+
labels, renderer buttons) has a key in `GridMessages`. Set the ones you need; the rest stay English.
|
|
2475
|
+
Functions get the values that go into the text.
|
|
2476
|
+
|
|
2477
|
+
```ts
|
|
2478
|
+
app.use(
|
|
2479
|
+
createVueGrid({
|
|
2480
|
+
messages: {
|
|
2481
|
+
sortAscending: 'Rastuće',
|
|
2482
|
+
empty: 'Nema podataka.',
|
|
2483
|
+
groupBy: (column) => `Grupiši po: ${column}`,
|
|
2484
|
+
pageSummary: (from, to, total) => `${from}–${to} od ${total}`,
|
|
2485
|
+
rowCount: (shown, total) => (total ? `${shown} od ${total} redova` : `${shown} redova`),
|
|
2486
|
+
},
|
|
2487
|
+
}),
|
|
2488
|
+
)
|
|
2489
|
+
```
|
|
2490
|
+
|
|
2491
|
+
A grid's own `:messages` win over the app's, and props that name a text (`empty-text`,
|
|
2492
|
+
`no-match-text`, `totals-label`, `<VGridSearch placeholder>`, a renderer's `label`…) win over both.
|
|
2493
|
+
`<VGridPagination>`, `<VGridSearch>`, `<VGridColumnMenu>` and `<VGridMenu>` use the app's messages on
|
|
2494
|
+
their own too. Every key, with its English default, is in the API reference (`GridMessages`).
|
|
2495
|
+
|
|
2496
|
+
**Parts.** `GridParts` turns off what a feature adds, each on by default; app-wide in
|
|
2497
|
+
`createVueGrid({ parts })`, per grid with `:parts`:
|
|
2498
|
+
|
|
2499
|
+
| Part | Leaves out |
|
|
2500
|
+
| -------------------- | ---------------------------------------------------------------------------- |
|
|
2501
|
+
| `progressBar` | The thin bar at the top while loading (`aria-busy` stays) |
|
|
2502
|
+
| `loadErrorNotice` | The notice above the rows when a request fails while rows are shown |
|
|
2503
|
+
| `retry` | The Retry buttons of load errors and of lazy children |
|
|
2504
|
+
| `clearFiltersButton` | The Clear filters button of the no-match message |
|
|
2505
|
+
| `selectAll` | The select-all checkbox in the header (rows still select) |
|
|
2506
|
+
| `selectAllBanner` | The "Select all N rows" banner (server data) |
|
|
2507
|
+
| `filterButtons` | The funnels in `filterable` headers (the filter row and search still filter) |
|
|
2508
|
+
| `resizeGrips` | The grips on header edges (Fit width / Reset width stay in the header menu) |
|
|
2509
|
+
| `headerDrag` | Dragging headers to reorder (Alt+←/→ and the header menu still move columns) |
|
|
2510
|
+
| `copyShortcut` | Ctrl/⌘+C copying in the grid (`copyRows()` still works) |
|
|
2511
|
+
| `groupCounts` | The row count on group rows |
|
|
2512
|
+
|
|
2513
|
+
Some parts can be replaced instead: `#load-error`, `#no-match`, `#select-all-banner` and
|
|
2514
|
+
`#status-bar`. The pager takes `pagination: { firstLast: false, summary: '' }`, the status bar
|
|
2515
|
+
`{ rows, selected, filters, clear }` flags. Per column, `sortable`, `filterable`, `resizable`,
|
|
2516
|
+
`reorderable`, `pinnable`, `hideable`, `groupable` and `exportable` work as before, and
|
|
2517
|
+
`header-menu` (`false`, or a function that edits the built-in items) shapes the header menu.
|
|
2518
|
+
|
|
2365
2519
|
## Theming
|
|
2366
2520
|
|
|
2367
2521
|
Override any token on `:root`, a wrapper, or the grid itself:
|