@vaadin/grid 23.2.0 → 23.2.1
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/package.json +10 -10
- package/src/vaadin-grid-column-reordering-mixin.js +22 -7
- package/src/vaadin-grid.js +8 -1
- package/web-types.json +28 -4
- package/web-types.lit.json +46 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/grid",
|
|
3
|
-
"version": "23.2.
|
|
3
|
+
"version": "23.2.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -45,17 +45,17 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
47
47
|
"@polymer/polymer": "^3.0.0",
|
|
48
|
-
"@vaadin/checkbox": "
|
|
49
|
-
"@vaadin/component-base": "
|
|
50
|
-
"@vaadin/lit-renderer": "
|
|
51
|
-
"@vaadin/text-field": "
|
|
52
|
-
"@vaadin/vaadin-lumo-styles": "
|
|
53
|
-
"@vaadin/vaadin-material-styles": "
|
|
54
|
-
"@vaadin/vaadin-themable-mixin": "
|
|
48
|
+
"@vaadin/checkbox": "~23.2.1",
|
|
49
|
+
"@vaadin/component-base": "~23.2.1",
|
|
50
|
+
"@vaadin/lit-renderer": "~23.2.1",
|
|
51
|
+
"@vaadin/text-field": "~23.2.1",
|
|
52
|
+
"@vaadin/vaadin-lumo-styles": "~23.2.1",
|
|
53
|
+
"@vaadin/vaadin-material-styles": "~23.2.1",
|
|
54
|
+
"@vaadin/vaadin-themable-mixin": "~23.2.1"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@esm-bundle/chai": "^4.3.4",
|
|
58
|
-
"@vaadin/polymer-legacy-adapter": "
|
|
58
|
+
"@vaadin/polymer-legacy-adapter": "~23.2.1",
|
|
59
59
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
60
60
|
"lit": "^2.0.0",
|
|
61
61
|
"sinon": "^13.0.2"
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"web-types.json",
|
|
65
65
|
"web-types.lit.json"
|
|
66
66
|
],
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "a6c314f6927bfd3309fc735eae6c6dc72ab8367a"
|
|
68
68
|
}
|
|
@@ -161,7 +161,23 @@ export const ColumnReorderingMixin = (superClass) =>
|
|
|
161
161
|
this._isSwapAllowed(this._draggedColumn, targetColumn) &&
|
|
162
162
|
this._isSwappableByPosition(targetColumn, e.detail.x)
|
|
163
163
|
) {
|
|
164
|
-
|
|
164
|
+
// Get the column header level of the target column (and the dragged column)
|
|
165
|
+
const columnTreeLevel = this._columnTree.findIndex((level) => level.includes(targetColumn));
|
|
166
|
+
// Get the columns on that level in visual order
|
|
167
|
+
const levelColumnsInOrder = this._getColumnsInOrder(columnTreeLevel);
|
|
168
|
+
|
|
169
|
+
// Index of the column being dragged
|
|
170
|
+
const startIndex = levelColumnsInOrder.indexOf(this._draggedColumn);
|
|
171
|
+
// Index of the column being dragged over
|
|
172
|
+
const endIndex = levelColumnsInOrder.indexOf(targetColumn);
|
|
173
|
+
|
|
174
|
+
// Direction of iteration
|
|
175
|
+
const direction = startIndex < endIndex ? 1 : -1;
|
|
176
|
+
|
|
177
|
+
// Iteratively swap all the columns from the dragged column to the target column
|
|
178
|
+
for (let i = startIndex; i !== endIndex; i += direction) {
|
|
179
|
+
this._swapColumnOrders(this._draggedColumn, levelColumnsInOrder[i + direction]);
|
|
180
|
+
}
|
|
165
181
|
}
|
|
166
182
|
|
|
167
183
|
this._updateGhostPosition(e.detail.x, this._touchDevice ? e.detail.y - 50 : e.detail.y);
|
|
@@ -192,15 +208,14 @@ export const ColumnReorderingMixin = (superClass) =>
|
|
|
192
208
|
}
|
|
193
209
|
|
|
194
210
|
/**
|
|
211
|
+
* Returns the columns (or column groups) on the specified header level in visual order.
|
|
212
|
+
* By default, the bottom level is used.
|
|
213
|
+
*
|
|
195
214
|
* @return {!Array<!GridColumn>}
|
|
196
215
|
* @protected
|
|
197
216
|
*/
|
|
198
|
-
_getColumnsInOrder() {
|
|
199
|
-
return this._columnTree
|
|
200
|
-
.slice(0)
|
|
201
|
-
.pop()
|
|
202
|
-
.filter((c) => !c.hidden)
|
|
203
|
-
.sort((b, a) => b._order - a._order);
|
|
217
|
+
_getColumnsInOrder(headerLevel = this._columnTree.length - 1) {
|
|
218
|
+
return this._columnTree[headerLevel].filter((c) => !c.hidden).sort((b, a) => b._order - a._order);
|
|
204
219
|
}
|
|
205
220
|
|
|
206
221
|
/**
|
package/src/vaadin-grid.js
CHANGED
|
@@ -594,6 +594,11 @@ class Grid extends ElementMixin(
|
|
|
594
594
|
// Flush to make sure DOM is up-to-date when measuring the column widths
|
|
595
595
|
this.__virtualizer.flush();
|
|
596
596
|
|
|
597
|
+
// Flush to account for any changes to the visibility of the columns
|
|
598
|
+
if (this._debouncerHiddenChanged) {
|
|
599
|
+
this._debouncerHiddenChanged.flush();
|
|
600
|
+
}
|
|
601
|
+
|
|
597
602
|
cols.forEach((col) => {
|
|
598
603
|
col.width = `${this.__getDistributedWidth(col)}px`;
|
|
599
604
|
});
|
|
@@ -995,7 +1000,9 @@ class Grid extends ElementMixin(
|
|
|
995
1000
|
// Header and footer renderers
|
|
996
1001
|
this._columnTree.forEach((level) => {
|
|
997
1002
|
level.forEach((column) => {
|
|
998
|
-
column._renderHeaderAndFooter
|
|
1003
|
+
if (column._renderHeaderAndFooter) {
|
|
1004
|
+
column._renderHeaderAndFooter();
|
|
1005
|
+
}
|
|
999
1006
|
});
|
|
1000
1007
|
});
|
|
1001
1008
|
|
package/web-types.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/grid",
|
|
4
|
-
"version": "23.2.
|
|
4
|
+
"version": "23.2.1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
8
8
|
"elements": [
|
|
9
9
|
{
|
|
10
10
|
"name": "vaadin-grid-column",
|
|
11
|
-
"description": "A `<vaadin-grid-column>` is used to configure how a column in `<vaadin-grid>`\nshould look like.\n\nSee [`<vaadin-grid>`](https://cdn.vaadin.com/vaadin-web-components/23.2.
|
|
11
|
+
"description": "A `<vaadin-grid-column>` is used to configure how a column in `<vaadin-grid>`\nshould look like.\n\nSee [`<vaadin-grid>`](https://cdn.vaadin.com/vaadin-web-components/23.2.1/#/elements/vaadin-grid) documentation for instructions on how\nto configure the `<vaadin-grid-column>`.",
|
|
12
12
|
"attributes": [
|
|
13
13
|
{
|
|
14
14
|
"name": "resizable",
|
|
@@ -765,7 +765,7 @@
|
|
|
765
765
|
},
|
|
766
766
|
{
|
|
767
767
|
"name": "vaadin-grid-selection-column",
|
|
768
|
-
"description": "`<vaadin-grid-selection-column>` is a helper element for the `<vaadin-grid>`\nthat provides default renderers and functionality for item selection.\n\n#### Example:\n```html\n<vaadin-grid items=\"[[items]]\">\n <vaadin-grid-selection-column frozen auto-select></vaadin-grid-selection-column>\n\n <vaadin-grid-column>\n ...\n```\n\nBy default the selection column displays `<vaadin-checkbox>` elements in the\ncolumn cells. The checkboxes in the body rows toggle selection of the corresponding row items.\n\nWhen the grid data is provided as an array of [`items`](https://cdn.vaadin.com/vaadin-web-components/23.2.
|
|
768
|
+
"description": "`<vaadin-grid-selection-column>` is a helper element for the `<vaadin-grid>`\nthat provides default renderers and functionality for item selection.\n\n#### Example:\n```html\n<vaadin-grid items=\"[[items]]\">\n <vaadin-grid-selection-column frozen auto-select></vaadin-grid-selection-column>\n\n <vaadin-grid-column>\n ...\n```\n\nBy default the selection column displays `<vaadin-checkbox>` elements in the\ncolumn cells. The checkboxes in the body rows toggle selection of the corresponding row items.\n\nWhen the grid data is provided as an array of [`items`](https://cdn.vaadin.com/vaadin-web-components/23.2.1/#/elements/vaadin-grid#property-items),\nthe column header gets an additional checkbox that can be used for toggling\nselection for all the items at once.\n\n__The default content can also be overridden__",
|
|
769
769
|
"attributes": [
|
|
770
770
|
{
|
|
771
771
|
"name": "resizable",
|
|
@@ -1059,6 +1059,10 @@
|
|
|
1059
1059
|
{
|
|
1060
1060
|
"name": "select-all-changed",
|
|
1061
1061
|
"description": "Fired when the `selectAll` property changes."
|
|
1062
|
+
},
|
|
1063
|
+
{
|
|
1064
|
+
"name": "selectAll-changed",
|
|
1065
|
+
"description": "Fired when the `selectAll` property changes."
|
|
1062
1066
|
}
|
|
1063
1067
|
]
|
|
1064
1068
|
}
|
|
@@ -1780,7 +1784,7 @@
|
|
|
1780
1784
|
},
|
|
1781
1785
|
{
|
|
1782
1786
|
"name": "vaadin-grid",
|
|
1783
|
-
"description": "`<vaadin-grid>` is a free, high quality data grid / data table Web Component. The content of the\nthe grid can be populated by using renderer callback function.\n\n### Quick Start\n\nStart with an assigning an array to the [`items`](https://cdn.vaadin.com/vaadin-web-components/23.2.
|
|
1787
|
+
"description": "`<vaadin-grid>` is a free, high quality data grid / data table Web Component. The content of the\nthe grid can be populated by using renderer callback function.\n\n### Quick Start\n\nStart with an assigning an array to the [`items`](https://cdn.vaadin.com/vaadin-web-components/23.2.1/#/elements/vaadin-grid#property-items) property to visualize your data.\n\nUse the [`<vaadin-grid-column>`](https://cdn.vaadin.com/vaadin-web-components/23.2.1/#/elements/vaadin-grid-column) element to configure the grid columns. Set `path` and `header`\nshorthand properties for the columns to define what gets rendered in the cells of the column.\n\n#### Example:\n```html\n<vaadin-grid>\n <vaadin-grid-column path=\"name.first\" header=\"First name\"></vaadin-grid-column>\n <vaadin-grid-column path=\"name.last\" header=\"Last name\"></vaadin-grid-column>\n <vaadin-grid-column path=\"email\"></vaadin-grid-column>\n</vaadin-grid>\n```\n\nFor custom content `vaadin-grid-column` element provides you with three types of `renderer` callback functions: `headerRenderer`,\n`renderer` and `footerRenderer`.\n\nEach of those renderer functions provides `root`, `column`, `model` arguments when applicable.\nGenerate DOM content, append it to the `root` element and control the state\nof the host element by accessing `column`. Before generating new content,\nusers are able to check if there is already content in `root` for reusing it.\n\nRenderers are called on initialization of new column cells and each time the\nrelated row model is updated. DOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n#### Example:\n```html\n<vaadin-grid>\n <vaadin-grid-column></vaadin-grid-column>\n <vaadin-grid-column></vaadin-grid-column>\n <vaadin-grid-column></vaadin-grid-column>\n</vaadin-grid>\n```\n```js\nconst grid = document.querySelector('vaadin-grid');\ngrid.items = [{'name': 'John', 'surname': 'Lennon', 'role': 'singer'},\n {'name': 'Ringo', 'surname': 'Starr', 'role': 'drums'}];\n\nconst columns = grid.querySelectorAll('vaadin-grid-column');\n\ncolumns[0].headerRenderer = function(root) {\n root.textContent = 'Name';\n};\ncolumns[0].renderer = function(root, column, model) {\n root.textContent = model.item.name;\n};\n\ncolumns[1].headerRenderer = function(root) {\n root.textContent = 'Surname';\n};\ncolumns[1].renderer = function(root, column, model) {\n root.textContent = model.item.surname;\n};\n\ncolumns[2].headerRenderer = function(root) {\n root.textContent = 'Role';\n};\ncolumns[2].renderer = function(root, column, model) {\n root.textContent = model.item.role;\n};\n```\n\nThe following properties are available in the `model` argument:\n\nProperty name | Type | Description\n--------------|------|------------\n`index`| Number | The index of the item.\n`item` | String or Object | The item.\n`level` | Number | Number of the item's tree sublevel, starts from 0.\n`expanded` | Boolean | True if the item's tree sublevel is expanded.\n`selected` | Boolean | True if the item is selected.\n`detailsOpened` | Boolean | True if the item's row details are open.\n\nThe following helper elements can be used for further customization:\n- [`<vaadin-grid-column-group>`](https://cdn.vaadin.com/vaadin-web-components/23.2.1/#/elements/vaadin-grid-column-group)\n- [`<vaadin-grid-filter>`](https://cdn.vaadin.com/vaadin-web-components/23.2.1/#/elements/vaadin-grid-filter)\n- [`<vaadin-grid-sorter>`](https://cdn.vaadin.com/vaadin-web-components/23.2.1/#/elements/vaadin-grid-sorter)\n- [`<vaadin-grid-selection-column>`](https://cdn.vaadin.com/vaadin-web-components/23.2.1/#/elements/vaadin-grid-selection-column)\n- [`<vaadin-grid-tree-toggle>`](https://cdn.vaadin.com/vaadin-web-components/23.2.1/#/elements/vaadin-grid-tree-toggle)\n\n__Note that the helper elements must be explicitly imported.__\nIf you want to import everything at once you can use the `all-imports.html` bundle.\n\n### Lazy Loading with Function Data Provider\n\nIn addition to assigning an array to the items property, you can alternatively\nprovide the `<vaadin-grid>` data through the\n[`dataProvider`](https://cdn.vaadin.com/vaadin-web-components/23.2.1/#/elements/vaadin-grid#property-dataProvider) function property.\nThe `<vaadin-grid>` calls this function lazily, only when it needs more data\nto be displayed.\n\nSee the [`dataProvider`](https://cdn.vaadin.com/vaadin-web-components/23.2.1/#/elements/vaadin-grid#property-dataProvider) in\nthe API reference below for the detailed data provider arguments description,\nand the “Assigning Data” page in the demos.\n\n__Note that expanding the tree grid's item will trigger a call to the `dataProvider`.__\n\n__Also, note that when using function data providers, the total number of items\nneeds to be set manually. The total number of items can be returned\nin the second argument of the data provider callback:__\n\n```javascript\ngrid.dataProvider = ({page, pageSize}, callback) => {\n // page: the requested page index\n // pageSize: number of items on one page\n const url = `https://api.example/data?page=${page}&per_page=${pageSize}`;\n\n fetch(url)\n .then((res) => res.json())\n .then(({ employees, totalSize }) => {\n callback(employees, totalSize);\n });\n};\n```\n\n__Alternatively, you can use the `size` property to set the total number of items:__\n\n```javascript\ngrid.size = 200; // The total number of items\ngrid.dataProvider = ({page, pageSize}, callback) => {\n const url = `https://api.example/data?page=${page}&per_page=${pageSize}`;\n\n fetch(url)\n .then((res) => res.json())\n .then((resJson) => callback(resJson.employees));\n};\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------------|----------------\n`row` | Row in the internal table\n`cell` | Cell in the internal table\n`header-cell` | Header cell in the internal table\n`body-cell` | Body cell in the internal table\n`footer-cell` | Footer cell in the internal table\n`details-cell` | Row details cell in the internal table\n`resize-handle` | Handle for resizing the columns\n`reorder-ghost` | Ghost element of the header cell being dragged\n\nThe following state attributes are available for styling:\n\nAttribute | Description | Part name\n-------------|-------------|------------\n`loading` | Set when the grid is loading data from data provider | :host\n`interacting` | Keyboard navigation in interaction mode | :host\n`navigating` | Keyboard navigation in navigation mode | :host\n`overflow` | Set when rows are overflowing the grid viewport. Possible values: `top`, `bottom`, `start`, `end` | :host\n`reordering` | Set when the grid's columns are being reordered | :host\n`dragover` | Set when the grid (not a specific row) is dragged over | :host\n`dragging-rows` | Set when grid rows are dragged | :host\n`reorder-status` | Reflects the status of a cell while columns are being reordered | cell\n`frozen` | Frozen cell | cell\n`last-frozen` | Last frozen cell | cell\n`first-column` | First visible cell on a row | cell\n`last-column` | Last visible cell on a row | cell\n`selected` | Selected row | row\n`expanded` | Expanded row | row\n`details-opened` | Row with details open | row\n`loading` | Row that is waiting for data from data provider | row\n`odd` | Odd row | row\n`first` | The first body row | row\n`last` | The last body row | row\n`dragstart` | Set for one frame when drag of a row is starting. The value is a number when multiple rows are dragged | row\n`dragover` | Set when the row is dragged over | row\n`drag-disabled` | Set to a row that isn't available for dragging | row\n`drop-disabled` | Set to a row that can't be dropped on top of | row\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
|
|
1784
1788
|
"attributes": [
|
|
1785
1789
|
{
|
|
1786
1790
|
"name": "size",
|
|
@@ -2142,6 +2146,26 @@
|
|
|
2142
2146
|
{
|
|
2143
2147
|
"name": "grid-drop",
|
|
2144
2148
|
"description": "Fired when a drop occurs on top of the grid."
|
|
2149
|
+
},
|
|
2150
|
+
{
|
|
2151
|
+
"name": "activeItem-changed",
|
|
2152
|
+
"description": "Fired when the `activeItem` property changes."
|
|
2153
|
+
},
|
|
2154
|
+
{
|
|
2155
|
+
"name": "size-changed",
|
|
2156
|
+
"description": "Fired when the `size` property changes."
|
|
2157
|
+
},
|
|
2158
|
+
{
|
|
2159
|
+
"name": "dataProvider-changed",
|
|
2160
|
+
"description": "Fired when the `dataProvider` property changes."
|
|
2161
|
+
},
|
|
2162
|
+
{
|
|
2163
|
+
"name": "expandedItems-changed",
|
|
2164
|
+
"description": "Fired when the `expandedItems` property changes."
|
|
2165
|
+
},
|
|
2166
|
+
{
|
|
2167
|
+
"name": "selectedItems-changed",
|
|
2168
|
+
"description": "Fired when the `selectedItems` property changes."
|
|
2145
2169
|
}
|
|
2146
2170
|
]
|
|
2147
2171
|
}
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/grid",
|
|
4
|
-
"version": "23.2.
|
|
4
|
+
"version": "23.2.1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"elements": [
|
|
17
17
|
{
|
|
18
18
|
"name": "vaadin-grid-column",
|
|
19
|
-
"description": "A `<vaadin-grid-column>` is used to configure how a column in `<vaadin-grid>`\nshould look like.\n\nSee [`<vaadin-grid>`](https://cdn.vaadin.com/vaadin-web-components/23.2.
|
|
19
|
+
"description": "A `<vaadin-grid-column>` is used to configure how a column in `<vaadin-grid>`\nshould look like.\n\nSee [`<vaadin-grid>`](https://cdn.vaadin.com/vaadin-web-components/23.2.1/#/elements/vaadin-grid) documentation for instructions on how\nto configure the `<vaadin-grid-column>`.",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|
|
@@ -303,7 +303,7 @@
|
|
|
303
303
|
},
|
|
304
304
|
{
|
|
305
305
|
"name": "vaadin-grid-selection-column",
|
|
306
|
-
"description": "`<vaadin-grid-selection-column>` is a helper element for the `<vaadin-grid>`\nthat provides default renderers and functionality for item selection.\n\n#### Example:\n```html\n<vaadin-grid items=\"[[items]]\">\n <vaadin-grid-selection-column frozen auto-select></vaadin-grid-selection-column>\n\n <vaadin-grid-column>\n ...\n```\n\nBy default the selection column displays `<vaadin-checkbox>` elements in the\ncolumn cells. The checkboxes in the body rows toggle selection of the corresponding row items.\n\nWhen the grid data is provided as an array of [`items`](https://cdn.vaadin.com/vaadin-web-components/23.2.
|
|
306
|
+
"description": "`<vaadin-grid-selection-column>` is a helper element for the `<vaadin-grid>`\nthat provides default renderers and functionality for item selection.\n\n#### Example:\n```html\n<vaadin-grid items=\"[[items]]\">\n <vaadin-grid-selection-column frozen auto-select></vaadin-grid-selection-column>\n\n <vaadin-grid-column>\n ...\n```\n\nBy default the selection column displays `<vaadin-checkbox>` elements in the\ncolumn cells. The checkboxes in the body rows toggle selection of the corresponding row items.\n\nWhen the grid data is provided as an array of [`items`](https://cdn.vaadin.com/vaadin-web-components/23.2.1/#/elements/vaadin-grid#property-items),\nthe column header gets an additional checkbox that can be used for toggling\nselection for all the items at once.\n\n__The default content can also be overridden__",
|
|
307
307
|
"extension": true,
|
|
308
308
|
"attributes": [
|
|
309
309
|
{
|
|
@@ -417,6 +417,13 @@
|
|
|
417
417
|
"value": {
|
|
418
418
|
"kind": "expression"
|
|
419
419
|
}
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
"name": "@selectAll-changed",
|
|
423
|
+
"description": "Fired when the `selectAll` property changes.",
|
|
424
|
+
"value": {
|
|
425
|
+
"kind": "expression"
|
|
426
|
+
}
|
|
420
427
|
}
|
|
421
428
|
]
|
|
422
429
|
},
|
|
@@ -702,7 +709,7 @@
|
|
|
702
709
|
},
|
|
703
710
|
{
|
|
704
711
|
"name": "vaadin-grid",
|
|
705
|
-
"description": "`<vaadin-grid>` is a free, high quality data grid / data table Web Component. The content of the\nthe grid can be populated by using renderer callback function.\n\n### Quick Start\n\nStart with an assigning an array to the [`items`](https://cdn.vaadin.com/vaadin-web-components/23.2.
|
|
712
|
+
"description": "`<vaadin-grid>` is a free, high quality data grid / data table Web Component. The content of the\nthe grid can be populated by using renderer callback function.\n\n### Quick Start\n\nStart with an assigning an array to the [`items`](https://cdn.vaadin.com/vaadin-web-components/23.2.1/#/elements/vaadin-grid#property-items) property to visualize your data.\n\nUse the [`<vaadin-grid-column>`](https://cdn.vaadin.com/vaadin-web-components/23.2.1/#/elements/vaadin-grid-column) element to configure the grid columns. Set `path` and `header`\nshorthand properties for the columns to define what gets rendered in the cells of the column.\n\n#### Example:\n```html\n<vaadin-grid>\n <vaadin-grid-column path=\"name.first\" header=\"First name\"></vaadin-grid-column>\n <vaadin-grid-column path=\"name.last\" header=\"Last name\"></vaadin-grid-column>\n <vaadin-grid-column path=\"email\"></vaadin-grid-column>\n</vaadin-grid>\n```\n\nFor custom content `vaadin-grid-column` element provides you with three types of `renderer` callback functions: `headerRenderer`,\n`renderer` and `footerRenderer`.\n\nEach of those renderer functions provides `root`, `column`, `model` arguments when applicable.\nGenerate DOM content, append it to the `root` element and control the state\nof the host element by accessing `column`. Before generating new content,\nusers are able to check if there is already content in `root` for reusing it.\n\nRenderers are called on initialization of new column cells and each time the\nrelated row model is updated. DOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n#### Example:\n```html\n<vaadin-grid>\n <vaadin-grid-column></vaadin-grid-column>\n <vaadin-grid-column></vaadin-grid-column>\n <vaadin-grid-column></vaadin-grid-column>\n</vaadin-grid>\n```\n```js\nconst grid = document.querySelector('vaadin-grid');\ngrid.items = [{'name': 'John', 'surname': 'Lennon', 'role': 'singer'},\n {'name': 'Ringo', 'surname': 'Starr', 'role': 'drums'}];\n\nconst columns = grid.querySelectorAll('vaadin-grid-column');\n\ncolumns[0].headerRenderer = function(root) {\n root.textContent = 'Name';\n};\ncolumns[0].renderer = function(root, column, model) {\n root.textContent = model.item.name;\n};\n\ncolumns[1].headerRenderer = function(root) {\n root.textContent = 'Surname';\n};\ncolumns[1].renderer = function(root, column, model) {\n root.textContent = model.item.surname;\n};\n\ncolumns[2].headerRenderer = function(root) {\n root.textContent = 'Role';\n};\ncolumns[2].renderer = function(root, column, model) {\n root.textContent = model.item.role;\n};\n```\n\nThe following properties are available in the `model` argument:\n\nProperty name | Type | Description\n--------------|------|------------\n`index`| Number | The index of the item.\n`item` | String or Object | The item.\n`level` | Number | Number of the item's tree sublevel, starts from 0.\n`expanded` | Boolean | True if the item's tree sublevel is expanded.\n`selected` | Boolean | True if the item is selected.\n`detailsOpened` | Boolean | True if the item's row details are open.\n\nThe following helper elements can be used for further customization:\n- [`<vaadin-grid-column-group>`](https://cdn.vaadin.com/vaadin-web-components/23.2.1/#/elements/vaadin-grid-column-group)\n- [`<vaadin-grid-filter>`](https://cdn.vaadin.com/vaadin-web-components/23.2.1/#/elements/vaadin-grid-filter)\n- [`<vaadin-grid-sorter>`](https://cdn.vaadin.com/vaadin-web-components/23.2.1/#/elements/vaadin-grid-sorter)\n- [`<vaadin-grid-selection-column>`](https://cdn.vaadin.com/vaadin-web-components/23.2.1/#/elements/vaadin-grid-selection-column)\n- [`<vaadin-grid-tree-toggle>`](https://cdn.vaadin.com/vaadin-web-components/23.2.1/#/elements/vaadin-grid-tree-toggle)\n\n__Note that the helper elements must be explicitly imported.__\nIf you want to import everything at once you can use the `all-imports.html` bundle.\n\n### Lazy Loading with Function Data Provider\n\nIn addition to assigning an array to the items property, you can alternatively\nprovide the `<vaadin-grid>` data through the\n[`dataProvider`](https://cdn.vaadin.com/vaadin-web-components/23.2.1/#/elements/vaadin-grid#property-dataProvider) function property.\nThe `<vaadin-grid>` calls this function lazily, only when it needs more data\nto be displayed.\n\nSee the [`dataProvider`](https://cdn.vaadin.com/vaadin-web-components/23.2.1/#/elements/vaadin-grid#property-dataProvider) in\nthe API reference below for the detailed data provider arguments description,\nand the “Assigning Data” page in the demos.\n\n__Note that expanding the tree grid's item will trigger a call to the `dataProvider`.__\n\n__Also, note that when using function data providers, the total number of items\nneeds to be set manually. The total number of items can be returned\nin the second argument of the data provider callback:__\n\n```javascript\ngrid.dataProvider = ({page, pageSize}, callback) => {\n // page: the requested page index\n // pageSize: number of items on one page\n const url = `https://api.example/data?page=${page}&per_page=${pageSize}`;\n\n fetch(url)\n .then((res) => res.json())\n .then(({ employees, totalSize }) => {\n callback(employees, totalSize);\n });\n};\n```\n\n__Alternatively, you can use the `size` property to set the total number of items:__\n\n```javascript\ngrid.size = 200; // The total number of items\ngrid.dataProvider = ({page, pageSize}, callback) => {\n const url = `https://api.example/data?page=${page}&per_page=${pageSize}`;\n\n fetch(url)\n .then((res) => res.json())\n .then((resJson) => callback(resJson.employees));\n};\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------------|----------------\n`row` | Row in the internal table\n`cell` | Cell in the internal table\n`header-cell` | Header cell in the internal table\n`body-cell` | Body cell in the internal table\n`footer-cell` | Footer cell in the internal table\n`details-cell` | Row details cell in the internal table\n`resize-handle` | Handle for resizing the columns\n`reorder-ghost` | Ghost element of the header cell being dragged\n\nThe following state attributes are available for styling:\n\nAttribute | Description | Part name\n-------------|-------------|------------\n`loading` | Set when the grid is loading data from data provider | :host\n`interacting` | Keyboard navigation in interaction mode | :host\n`navigating` | Keyboard navigation in navigation mode | :host\n`overflow` | Set when rows are overflowing the grid viewport. Possible values: `top`, `bottom`, `start`, `end` | :host\n`reordering` | Set when the grid's columns are being reordered | :host\n`dragover` | Set when the grid (not a specific row) is dragged over | :host\n`dragging-rows` | Set when grid rows are dragged | :host\n`reorder-status` | Reflects the status of a cell while columns are being reordered | cell\n`frozen` | Frozen cell | cell\n`last-frozen` | Last frozen cell | cell\n`first-column` | First visible cell on a row | cell\n`last-column` | Last visible cell on a row | cell\n`selected` | Selected row | row\n`expanded` | Expanded row | row\n`details-opened` | Row with details open | row\n`loading` | Row that is waiting for data from data provider | row\n`odd` | Odd row | row\n`first` | The first body row | row\n`last` | The last body row | row\n`dragstart` | Set for one frame when drag of a row is starting. The value is a number when multiple rows are dragged | row\n`dragover` | Set when the row is dragged over | row\n`drag-disabled` | Set to a row that isn't available for dragging | row\n`drop-disabled` | Set to a row that can't be dropped on top of | row\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
|
|
706
713
|
"extension": true,
|
|
707
714
|
"attributes": [
|
|
708
715
|
{
|
|
@@ -921,6 +928,41 @@
|
|
|
921
928
|
"value": {
|
|
922
929
|
"kind": "expression"
|
|
923
930
|
}
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
"name": "@activeItem-changed",
|
|
934
|
+
"description": "Fired when the `activeItem` property changes.",
|
|
935
|
+
"value": {
|
|
936
|
+
"kind": "expression"
|
|
937
|
+
}
|
|
938
|
+
},
|
|
939
|
+
{
|
|
940
|
+
"name": "@size-changed",
|
|
941
|
+
"description": "Fired when the `size` property changes.",
|
|
942
|
+
"value": {
|
|
943
|
+
"kind": "expression"
|
|
944
|
+
}
|
|
945
|
+
},
|
|
946
|
+
{
|
|
947
|
+
"name": "@dataProvider-changed",
|
|
948
|
+
"description": "Fired when the `dataProvider` property changes.",
|
|
949
|
+
"value": {
|
|
950
|
+
"kind": "expression"
|
|
951
|
+
}
|
|
952
|
+
},
|
|
953
|
+
{
|
|
954
|
+
"name": "@expandedItems-changed",
|
|
955
|
+
"description": "Fired when the `expandedItems` property changes.",
|
|
956
|
+
"value": {
|
|
957
|
+
"kind": "expression"
|
|
958
|
+
}
|
|
959
|
+
},
|
|
960
|
+
{
|
|
961
|
+
"name": "@selectedItems-changed",
|
|
962
|
+
"description": "Fired when the `selectedItems` property changes.",
|
|
963
|
+
"value": {
|
|
964
|
+
"kind": "expression"
|
|
965
|
+
}
|
|
924
966
|
}
|
|
925
967
|
]
|
|
926
968
|
}
|