@vaadin/grid 24.1.0-alpha4 → 24.1.0-alpha5
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.js +10 -1
- package/src/vaadin-grid-keyboard-navigation-mixin.js +26 -3
- package/src/vaadin-grid-scroll-mixin.d.ts +38 -0
- package/src/vaadin-grid-scroll-mixin.js +199 -1
- package/src/vaadin-grid-styles.js +4 -0
- package/src/vaadin-grid-tree-column.js +1 -1
- package/src/vaadin-grid.js +24 -10
- package/web-types.json +22 -4
- package/web-types.lit.json +11 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/grid",
|
|
3
|
-
"version": "24.1.0-
|
|
3
|
+
"version": "24.1.0-alpha5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
48
48
|
"@polymer/polymer": "^3.0.0",
|
|
49
|
-
"@vaadin/a11y-base": "24.1.0-
|
|
50
|
-
"@vaadin/checkbox": "24.1.0-
|
|
51
|
-
"@vaadin/component-base": "24.1.0-
|
|
52
|
-
"@vaadin/lit-renderer": "24.1.0-
|
|
53
|
-
"@vaadin/text-field": "24.1.0-
|
|
54
|
-
"@vaadin/vaadin-lumo-styles": "24.1.0-
|
|
55
|
-
"@vaadin/vaadin-material-styles": "24.1.0-
|
|
56
|
-
"@vaadin/vaadin-themable-mixin": "24.1.0-
|
|
49
|
+
"@vaadin/a11y-base": "24.1.0-alpha5",
|
|
50
|
+
"@vaadin/checkbox": "24.1.0-alpha5",
|
|
51
|
+
"@vaadin/component-base": "24.1.0-alpha5",
|
|
52
|
+
"@vaadin/lit-renderer": "24.1.0-alpha5",
|
|
53
|
+
"@vaadin/text-field": "24.1.0-alpha5",
|
|
54
|
+
"@vaadin/vaadin-lumo-styles": "24.1.0-alpha5",
|
|
55
|
+
"@vaadin/vaadin-material-styles": "24.1.0-alpha5",
|
|
56
|
+
"@vaadin/vaadin-themable-mixin": "24.1.0-alpha5"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@esm-bundle/chai": "^4.3.4",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"web-types.json",
|
|
66
66
|
"web-types.lit.json"
|
|
67
67
|
],
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "1ab6c977fe239d94aac5f39940c1a4722ad4bb63"
|
|
69
69
|
}
|
|
@@ -95,6 +95,15 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
95
95
|
value: false,
|
|
96
96
|
},
|
|
97
97
|
|
|
98
|
+
/**
|
|
99
|
+
* @type {boolean}
|
|
100
|
+
* @protected
|
|
101
|
+
*/
|
|
102
|
+
_bodyContentHidden: {
|
|
103
|
+
type: Boolean,
|
|
104
|
+
value: false,
|
|
105
|
+
},
|
|
106
|
+
|
|
98
107
|
/**
|
|
99
108
|
* @type {boolean}
|
|
100
109
|
* @protected
|
|
@@ -207,7 +216,7 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
207
216
|
'_orderChanged(_order, _headerCell, _footerCell, _cells.*)',
|
|
208
217
|
'_lastFrozenChanged(_lastFrozen)',
|
|
209
218
|
'_firstFrozenToEndChanged(_firstFrozenToEnd)',
|
|
210
|
-
'_onRendererOrBindingChanged(_renderer, _cells, _cells.*, path)',
|
|
219
|
+
'_onRendererOrBindingChanged(_renderer, _cells, _bodyContentHidden, _cells.*, path)',
|
|
211
220
|
'_onHeaderRendererOrBindingChanged(_headerRenderer, _headerCell, path, header)',
|
|
212
221
|
'_onFooterRendererOrBindingChanged(_footerRenderer, _footerCell)',
|
|
213
222
|
'_resizableChanged(resizable, _headerCell)',
|
|
@@ -521,7 +521,12 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
521
521
|
return;
|
|
522
522
|
}
|
|
523
523
|
|
|
524
|
-
|
|
524
|
+
let columnIndex = this.__getIndexOfChildElement(activeCell);
|
|
525
|
+
if (this.$.items.contains(activeCell)) {
|
|
526
|
+
// lazy column rendering may be enabled, so we need use the always visible sizer cells to find the column index
|
|
527
|
+
columnIndex = [...this.$.sizer.children].findIndex((sizerCell) => sizerCell._column === activeCell._column);
|
|
528
|
+
}
|
|
529
|
+
|
|
525
530
|
const isCurrentCellRowDetails = this.__isDetailsCell(activeCell);
|
|
526
531
|
const activeRowGroup = activeRow.parentNode;
|
|
527
532
|
const currentRowIndex = this.__getIndexInGroup(activeRow, this._focusedItemIndex);
|
|
@@ -574,9 +579,27 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
574
579
|
return acc;
|
|
575
580
|
}, {});
|
|
576
581
|
const dstColumnIndex = columnIndexByOrder[dstSortedColumnOrders[dstOrderedColumnIndex]];
|
|
577
|
-
const dstCell = dstRow.children[dstColumnIndex];
|
|
578
582
|
|
|
579
|
-
|
|
583
|
+
let dstCell;
|
|
584
|
+
if (this.$.items.contains(activeCell)) {
|
|
585
|
+
const dstSizerCell = this.$.sizer.children[dstColumnIndex];
|
|
586
|
+
if (this._lazyColumns) {
|
|
587
|
+
// If the column is not in the viewport, scroll it into view.
|
|
588
|
+
if (!this.__isColumnInViewport(dstSizerCell._column)) {
|
|
589
|
+
dstSizerCell.scrollIntoView();
|
|
590
|
+
}
|
|
591
|
+
this.__updateColumnsBodyContentHidden();
|
|
592
|
+
this.__updateHorizontalScrollPosition();
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
dstCell = [...dstRow.children].find((cell) => cell._column === dstSizerCell._column);
|
|
596
|
+
// Ensure correct horizontal scroll position once the destination cell is available.
|
|
597
|
+
this._scrollHorizontallyToCell(dstCell);
|
|
598
|
+
} else {
|
|
599
|
+
dstCell = dstRow.children[dstColumnIndex];
|
|
600
|
+
this._scrollHorizontallyToCell(dstCell);
|
|
601
|
+
}
|
|
602
|
+
|
|
580
603
|
dstCell.focus();
|
|
581
604
|
}
|
|
582
605
|
}
|
|
@@ -7,7 +7,45 @@ import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
|
7
7
|
|
|
8
8
|
export declare function ScrollMixin<T extends Constructor<HTMLElement>>(base: T): Constructor<ScrollMixinClass> & T;
|
|
9
9
|
|
|
10
|
+
export type ColumnRendering = 'eager' | 'lazy';
|
|
11
|
+
|
|
10
12
|
export declare class ScrollMixinClass {
|
|
13
|
+
/**
|
|
14
|
+
* Allows you to choose between modes for rendering columns in the grid:
|
|
15
|
+
*
|
|
16
|
+
* "eager" (default): All columns are rendered upfront, regardless of their visibility within the viewport.
|
|
17
|
+
* This mode should generally be preferred, as it avoids the limitations imposed by the "lazy" mode.
|
|
18
|
+
* Use this mode unless the grid has a large number of columns and performance outweighs the limitations
|
|
19
|
+
* in priority.
|
|
20
|
+
*
|
|
21
|
+
* "lazy": Optimizes the rendering of cells when there are multiple columns in the grid by virtualizing
|
|
22
|
+
* horizontal scrolling. In this mode, body cells are rendered only when their corresponding columns are
|
|
23
|
+
* inside the visible viewport.
|
|
24
|
+
*
|
|
25
|
+
* Using "lazy" rendering should be used only if you're dealing with a large number of columns and performance
|
|
26
|
+
* is your highest priority. For most use cases, the default "eager" mode is recommended due to the
|
|
27
|
+
* limitations imposed by the "lazy" mode.
|
|
28
|
+
*
|
|
29
|
+
* When using the "lazy" mode, keep the following limitations in mind:
|
|
30
|
+
*
|
|
31
|
+
* - Row Height: When only a number of columns are visible at once, the height of a row can only be that of
|
|
32
|
+
* the highest cell currently visible on that row. Make sure each cell on a single row has the same height
|
|
33
|
+
* as all other cells on that row. If row cells have different heights, users may experience jumpiness when
|
|
34
|
+
* scrolling the grid horizontally as lazily rendered cells with different heights are scrolled into view.
|
|
35
|
+
*
|
|
36
|
+
* - Auto-width Columns: For the columns that are initially outside the visible viewport but still use auto-width,
|
|
37
|
+
* only the header content is taken into account when calculating the column width because the body cells
|
|
38
|
+
* of the columns outside the viewport are not initially rendered.
|
|
39
|
+
*
|
|
40
|
+
* - Screen Reader Compatibility: Screen readers may not be able to associate the focused cells with the correct
|
|
41
|
+
* headers when only a subset of the body cells on a row is rendered.
|
|
42
|
+
*
|
|
43
|
+
* - Keyboard Navigation: Tabbing through focusable elements inside the grid body may not work as expected because
|
|
44
|
+
* some of the columns that would include focusable elements in the body cells may be outside the visible viewport
|
|
45
|
+
* and thus not rendered.
|
|
46
|
+
*/
|
|
47
|
+
columnRendering: ColumnRendering;
|
|
48
|
+
|
|
11
49
|
/**
|
|
12
50
|
* Scroll to a flat index in the grid. The method doesn't take into account
|
|
13
51
|
* the hierarchy of the items.
|
|
@@ -10,6 +10,7 @@ import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
|
|
|
10
10
|
|
|
11
11
|
const timeouts = {
|
|
12
12
|
SCROLLING: 500,
|
|
13
|
+
UPDATE_CONTENT_VISIBILITY: 100,
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -19,6 +20,48 @@ export const ScrollMixin = (superClass) =>
|
|
|
19
20
|
class ScrollMixin extends ResizeMixin(superClass) {
|
|
20
21
|
static get properties() {
|
|
21
22
|
return {
|
|
23
|
+
/**
|
|
24
|
+
* Allows you to choose between modes for rendering columns in the grid:
|
|
25
|
+
*
|
|
26
|
+
* "eager" (default): All columns are rendered upfront, regardless of their visibility within the viewport.
|
|
27
|
+
* This mode should generally be preferred, as it avoids the limitations imposed by the "lazy" mode.
|
|
28
|
+
* Use this mode unless the grid has a large number of columns and performance outweighs the limitations
|
|
29
|
+
* in priority.
|
|
30
|
+
*
|
|
31
|
+
* "lazy": Optimizes the rendering of cells when there are multiple columns in the grid by virtualizing
|
|
32
|
+
* horizontal scrolling. In this mode, body cells are rendered only when their corresponding columns are
|
|
33
|
+
* inside the visible viewport.
|
|
34
|
+
*
|
|
35
|
+
* Using "lazy" rendering should be used only if you're dealing with a large number of columns and performance
|
|
36
|
+
* is your highest priority. For most use cases, the default "eager" mode is recommended due to the
|
|
37
|
+
* limitations imposed by the "lazy" mode.
|
|
38
|
+
*
|
|
39
|
+
* When using the "lazy" mode, keep the following limitations in mind:
|
|
40
|
+
*
|
|
41
|
+
* - Row Height: When only a number of columns are visible at once, the height of a row can only be that of
|
|
42
|
+
* the highest cell currently visible on that row. Make sure each cell on a single row has the same height
|
|
43
|
+
* as all other cells on that row. If row cells have different heights, users may experience jumpiness when
|
|
44
|
+
* scrolling the grid horizontally as lazily rendered cells with different heights are scrolled into view.
|
|
45
|
+
*
|
|
46
|
+
* - Auto-width Columns: For the columns that are initially outside the visible viewport but still use auto-width,
|
|
47
|
+
* only the header content is taken into account when calculating the column width because the body cells
|
|
48
|
+
* of the columns outside the viewport are not initially rendered.
|
|
49
|
+
*
|
|
50
|
+
* - Screen Reader Compatibility: Screen readers may not be able to associate the focused cells with the correct
|
|
51
|
+
* headers when only a subset of the body cells on a row is rendered.
|
|
52
|
+
*
|
|
53
|
+
* - Keyboard Navigation: Tabbing through focusable elements inside the grid body may not work as expected because
|
|
54
|
+
* some of the columns that would include focusable elements in the body cells may be outside the visible viewport
|
|
55
|
+
* and thus not rendered.
|
|
56
|
+
*
|
|
57
|
+
* @attr {eager|lazy} column-rendering
|
|
58
|
+
* @type {!ColumnRendering}
|
|
59
|
+
*/
|
|
60
|
+
columnRendering: {
|
|
61
|
+
type: String,
|
|
62
|
+
value: 'eager',
|
|
63
|
+
},
|
|
64
|
+
|
|
22
65
|
/**
|
|
23
66
|
* Cached array of frozen cells
|
|
24
67
|
* @private
|
|
@@ -42,6 +85,10 @@ export const ScrollMixin = (superClass) =>
|
|
|
42
85
|
};
|
|
43
86
|
}
|
|
44
87
|
|
|
88
|
+
static get observers() {
|
|
89
|
+
return ['__columnRenderingChanged(_columnTree, columnRendering)'];
|
|
90
|
+
}
|
|
91
|
+
|
|
45
92
|
/** @private */
|
|
46
93
|
get _scrollLeft() {
|
|
47
94
|
return this.$.table.scrollLeft;
|
|
@@ -60,6 +107,11 @@ export const ScrollMixin = (superClass) =>
|
|
|
60
107
|
this.$.table.scrollTop = top;
|
|
61
108
|
}
|
|
62
109
|
|
|
110
|
+
/** @protected */
|
|
111
|
+
get _lazyColumns() {
|
|
112
|
+
return this.columnRendering === 'lazy';
|
|
113
|
+
}
|
|
114
|
+
|
|
63
115
|
/** @protected */
|
|
64
116
|
ready() {
|
|
65
117
|
super.ready();
|
|
@@ -143,6 +195,124 @@ export const ScrollMixin = (superClass) =>
|
|
|
143
195
|
}
|
|
144
196
|
|
|
145
197
|
this._updateOverflow();
|
|
198
|
+
|
|
199
|
+
this._debounceColumnContentVisibility = Debouncer.debounce(
|
|
200
|
+
this._debounceColumnContentVisibility,
|
|
201
|
+
timeOut.after(timeouts.UPDATE_CONTENT_VISIBILITY),
|
|
202
|
+
() => {
|
|
203
|
+
// If horizontal scroll position changed and lazy column rendering is enabled,
|
|
204
|
+
// update the visible columns.
|
|
205
|
+
if (this._lazyColumns && this.__cachedScrollLeft !== this._scrollLeft) {
|
|
206
|
+
this.__cachedScrollLeft = this._scrollLeft;
|
|
207
|
+
this.__updateColumnsBodyContentHidden();
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** @private */
|
|
214
|
+
__updateColumnsBodyContentHidden() {
|
|
215
|
+
if (!this._columnTree) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const columnsInOrder = this._getColumnsInOrder();
|
|
220
|
+
|
|
221
|
+
// Return if sizer cells are not yet assigned to columns
|
|
222
|
+
if (!columnsInOrder[0] || !columnsInOrder[0]._sizerCell) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
let bodyContentHiddenChanged = false;
|
|
227
|
+
|
|
228
|
+
// Remove the column cells from the DOM if the column is outside the viewport.
|
|
229
|
+
// Add the column cells to the DOM if the column is inside the viewport.
|
|
230
|
+
//
|
|
231
|
+
// Update the _bodyContentHidden property of the column to reflect the current
|
|
232
|
+
// visibility state and make it run renderers for the cells if necessary.
|
|
233
|
+
columnsInOrder.forEach((column) => {
|
|
234
|
+
const bodyContentHidden = this._lazyColumns && !this.__isColumnInViewport(column);
|
|
235
|
+
|
|
236
|
+
if (column._bodyContentHidden !== bodyContentHidden) {
|
|
237
|
+
bodyContentHiddenChanged = true;
|
|
238
|
+
column._cells.forEach((cell) => {
|
|
239
|
+
if (cell !== column._sizerCell) {
|
|
240
|
+
if (bodyContentHidden) {
|
|
241
|
+
cell.remove();
|
|
242
|
+
} else if (cell.__parentRow) {
|
|
243
|
+
// Add the cell to the correct DOM position in the row
|
|
244
|
+
const followingColumnCell = [...cell.__parentRow.children].find(
|
|
245
|
+
(child) => columnsInOrder.indexOf(child._column) > columnsInOrder.indexOf(column),
|
|
246
|
+
);
|
|
247
|
+
cell.__parentRow.insertBefore(cell, followingColumnCell);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
column._bodyContentHidden = bodyContentHidden;
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
if (bodyContentHiddenChanged) {
|
|
257
|
+
// Frozen columns may have changed their visibility
|
|
258
|
+
this._frozenCellsChanged();
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (this._lazyColumns) {
|
|
262
|
+
// Calculate the offset to apply to the body cells
|
|
263
|
+
const lastFrozenColumn = [...columnsInOrder].reverse().find((column) => column.frozen);
|
|
264
|
+
const lastFrozenColumnEnd = this.__getColumnEnd(lastFrozenColumn);
|
|
265
|
+
const firstVisibleColumn = columnsInOrder.find((column) => !column.frozen && !column._bodyContentHidden);
|
|
266
|
+
this.__lazyColumnsStart = this.__getColumnStart(firstVisibleColumn) - lastFrozenColumnEnd;
|
|
267
|
+
this.$.items.style.setProperty('--_grid-lazy-columns-start', `${this.__lazyColumnsStart}px`);
|
|
268
|
+
|
|
269
|
+
// Make sure the body has a focusable element in lazy columns mode
|
|
270
|
+
this._resetKeyboardNavigation();
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** @private */
|
|
275
|
+
__getColumnEnd(column) {
|
|
276
|
+
if (!column) {
|
|
277
|
+
return this.__isRTL ? this.$.table.clientWidth : 0;
|
|
278
|
+
}
|
|
279
|
+
return column._sizerCell.offsetLeft + (this.__isRTL ? 0 : column._sizerCell.offsetWidth);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** @private */
|
|
283
|
+
__getColumnStart(column) {
|
|
284
|
+
if (!column) {
|
|
285
|
+
return this.__isRTL ? this.$.table.clientWidth : 0;
|
|
286
|
+
}
|
|
287
|
+
return column._sizerCell.offsetLeft + (this.__isRTL ? column._sizerCell.offsetWidth : 0);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Returns true if the given column is horizontally inside the viewport.
|
|
292
|
+
* @private
|
|
293
|
+
*/
|
|
294
|
+
__isColumnInViewport(column) {
|
|
295
|
+
if (column.frozen || column.frozenToEnd) {
|
|
296
|
+
// Assume frozen columns to always be inside the viewport
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Check if the column's sizer cell is inside the viewport
|
|
301
|
+
return (
|
|
302
|
+
column._sizerCell.offsetLeft + column._sizerCell.offsetWidth >= this._scrollLeft &&
|
|
303
|
+
column._sizerCell.offsetLeft <= this._scrollLeft + this.clientWidth
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/** @private */
|
|
308
|
+
__columnRenderingChanged(_columnTree, columnRendering) {
|
|
309
|
+
if (columnRendering === 'eager') {
|
|
310
|
+
this.$.scroller.removeAttribute('column-rendering');
|
|
311
|
+
} else {
|
|
312
|
+
this.$.scroller.setAttribute('column-rendering', columnRendering);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
this.__updateColumnsBodyContentHidden();
|
|
146
316
|
}
|
|
147
317
|
|
|
148
318
|
/** @private */
|
|
@@ -254,10 +424,15 @@ export const ScrollMixin = (superClass) =>
|
|
|
254
424
|
if (firstFrozenToEnd !== undefined) {
|
|
255
425
|
columnsRow[firstFrozenToEnd]._firstFrozenToEnd = true;
|
|
256
426
|
}
|
|
427
|
+
|
|
428
|
+
this.__updateColumnsBodyContentHidden();
|
|
257
429
|
}
|
|
258
430
|
|
|
259
431
|
/** @private */
|
|
260
432
|
__updateHorizontalScrollPosition() {
|
|
433
|
+
if (!this._columnTree) {
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
261
436
|
const scrollWidth = this.$.table.scrollWidth;
|
|
262
437
|
const clientWidth = this.$.table.clientWidth;
|
|
263
438
|
const scrollLeft = Math.max(0, this.$.table.scrollLeft);
|
|
@@ -279,8 +454,31 @@ export const ScrollMixin = (superClass) =>
|
|
|
279
454
|
// Position cells frozen to end
|
|
280
455
|
const remaining = this.__isRTL ? normalizedScrollLeft : scrollLeft + clientWidth - scrollWidth;
|
|
281
456
|
const transformFrozenToEnd = `translate(${remaining}px, 0)`;
|
|
457
|
+
|
|
458
|
+
let transformFrozenToEndBody = transformFrozenToEnd;
|
|
459
|
+
|
|
460
|
+
if (this._lazyColumns) {
|
|
461
|
+
// Lazy column rendering is used, calculate the offset to apply to the frozen to end cells
|
|
462
|
+
const columnsInOrder = this._getColumnsInOrder();
|
|
463
|
+
|
|
464
|
+
const lastVisibleColumn = [...columnsInOrder]
|
|
465
|
+
.reverse()
|
|
466
|
+
.find((column) => !column.frozenToEnd && !column._bodyContentHidden);
|
|
467
|
+
const lastVisibleColumnEnd = this.__getColumnEnd(lastVisibleColumn);
|
|
468
|
+
|
|
469
|
+
const firstFrozenToEndColumn = columnsInOrder.find((column) => column.frozenToEnd);
|
|
470
|
+
const firstFrozenToEndColumnStart = this.__getColumnStart(firstFrozenToEndColumn);
|
|
471
|
+
|
|
472
|
+
const translateX = remaining + (firstFrozenToEndColumnStart - lastVisibleColumnEnd) + this.__lazyColumnsStart;
|
|
473
|
+
transformFrozenToEndBody = `translate(${translateX}px, 0)`;
|
|
474
|
+
}
|
|
475
|
+
|
|
282
476
|
this._frozenToEndCells.forEach((cell) => {
|
|
283
|
-
cell
|
|
477
|
+
if (this.$.items.contains(cell)) {
|
|
478
|
+
cell.style.transform = transformFrozenToEndBody;
|
|
479
|
+
} else {
|
|
480
|
+
cell.style.transform = transformFrozenToEnd;
|
|
481
|
+
}
|
|
284
482
|
});
|
|
285
483
|
|
|
286
484
|
// Only update the --_grid-horizontal-scroll-position custom property when navigating
|
|
@@ -125,6 +125,10 @@ registerStyles(
|
|
|
125
125
|
opacity: 0;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
[column-rendering='lazy'] [part~='body-cell']:not([frozen]):not([frozen-to-end]) {
|
|
129
|
+
transform: translateX(var(--_grid-lazy-columns-start));
|
|
130
|
+
}
|
|
131
|
+
|
|
128
132
|
#items [part~='row'] {
|
|
129
133
|
position: absolute;
|
|
130
134
|
}
|
|
@@ -34,7 +34,7 @@ class GridTreeColumn extends GridColumn {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
static get observers() {
|
|
37
|
-
return ['_onRendererOrBindingChanged(_renderer, _cells, _cells.*, path)'];
|
|
37
|
+
return ['_onRendererOrBindingChanged(_renderer, _cells, _bodyContentHidden, _cells.*, path)'];
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
constructor() {
|
package/src/vaadin-grid.js
CHANGED
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import './vaadin-grid-column.js';
|
|
7
7
|
import './vaadin-grid-styles.js';
|
|
8
|
-
import { beforeNextRender } from '@polymer/polymer/lib/utils/render-status.js';
|
|
9
8
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
10
9
|
import { TabindexMixin } from '@vaadin/a11y-base/src/tabindex-mixin.js';
|
|
11
|
-
import { microTask } from '@vaadin/component-base/src/async.js';
|
|
10
|
+
import { animationFrame, microTask } from '@vaadin/component-base/src/async.js';
|
|
12
11
|
import { isAndroid, isChrome, isFirefox, isIOS, isSafari, isTouch } from '@vaadin/component-base/src/browser-utils.js';
|
|
13
12
|
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
14
13
|
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
@@ -503,7 +502,12 @@ class Grid extends ElementMixin(
|
|
|
503
502
|
reorderElements: true,
|
|
504
503
|
});
|
|
505
504
|
|
|
506
|
-
new ResizeObserver(() =>
|
|
505
|
+
new ResizeObserver(() =>
|
|
506
|
+
setTimeout(() => {
|
|
507
|
+
this.__updateFooterPositioning();
|
|
508
|
+
this.__updateColumnsBodyContentHidden();
|
|
509
|
+
}),
|
|
510
|
+
).observe(this.$.table);
|
|
507
511
|
|
|
508
512
|
processTemplates(this);
|
|
509
513
|
|
|
@@ -741,12 +745,14 @@ class Grid extends ElementMixin(
|
|
|
741
745
|
);
|
|
742
746
|
}
|
|
743
747
|
|
|
744
|
-
|
|
745
|
-
this.
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
748
|
+
this.__afterCreateScrollerRowsDebouncer = Debouncer.debounce(
|
|
749
|
+
this.__afterCreateScrollerRowsDebouncer,
|
|
750
|
+
animationFrame,
|
|
751
|
+
() => {
|
|
752
|
+
this._afterScroll();
|
|
753
|
+
this.__itemsReceived();
|
|
754
|
+
},
|
|
755
|
+
);
|
|
750
756
|
return rows;
|
|
751
757
|
}
|
|
752
758
|
|
|
@@ -865,7 +871,14 @@ class Grid extends ElementMixin(
|
|
|
865
871
|
column._cells.push(cell);
|
|
866
872
|
}
|
|
867
873
|
cell.setAttribute('part', 'cell body-cell');
|
|
868
|
-
row
|
|
874
|
+
cell.__parentRow = row;
|
|
875
|
+
if (!column._bodyContentHidden) {
|
|
876
|
+
row.appendChild(cell);
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
if (row === this.$.sizer) {
|
|
880
|
+
column._sizerCell = cell;
|
|
881
|
+
}
|
|
869
882
|
|
|
870
883
|
if (index === cols.length - 1 && this.rowDetailsRenderer) {
|
|
871
884
|
// Add details cell as last cell to body rows
|
|
@@ -1004,6 +1017,7 @@ class Grid extends ElementMixin(
|
|
|
1004
1017
|
_columnTreeChanged(columnTree) {
|
|
1005
1018
|
this._renderColumnTree(columnTree);
|
|
1006
1019
|
this.recalculateColumnWidths();
|
|
1020
|
+
this.__updateColumnsBodyContentHidden();
|
|
1007
1021
|
}
|
|
1008
1022
|
|
|
1009
1023
|
/** @private */
|
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": "24.1.0-
|
|
4
|
+
"version": "24.1.0-alpha5",
|
|
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/24.1.0-
|
|
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/24.1.0-alpha5/#/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/24.1.0-
|
|
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/24.1.0-alpha5/#/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",
|
|
@@ -1758,7 +1758,7 @@
|
|
|
1758
1758
|
},
|
|
1759
1759
|
{
|
|
1760
1760
|
"name": "vaadin-grid",
|
|
1761
|
-
"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/24.1.0-alpha4/#/elements/vaadin-grid#property-items) property to visualize your data.\n\nUse the [`<vaadin-grid-column>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha4/#/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/24.1.0-alpha4/#/elements/vaadin-grid-column-group)\n- [`<vaadin-grid-filter>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha4/#/elements/vaadin-grid-filter)\n- [`<vaadin-grid-sorter>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha4/#/elements/vaadin-grid-sorter)\n- [`<vaadin-grid-selection-column>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha4/#/elements/vaadin-grid-selection-column)\n- [`<vaadin-grid-tree-toggle>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha4/#/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/24.1.0-alpha4/#/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/24.1.0-alpha4/#/elements/vaadin-grid#property-dataProvider) property\ndocumentation for the detailed data provider arguments description.\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`expanded-row` | Expanded row\n`selected-row` | Selected row\n`details-opened-row` | Row with details open\n`odd-row` | Odd row\n`even-row` | Even row\n`first-row` | The first body row\n`last-row` | The last body row\n`dragstart-row` | Set on the row for one frame when drag is starting.\n`dragover-above-row` | Set on the row when the a row is dragged over above\n`dragover-below-row` | Set on the row when the a row is dragged over below\n`dragover-on-top-row` | Set on the row when the a row is dragged over on top\n`drag-disabled-row` | Set to a row that isn't available for dragging\n`drop-disabled-row` | Set to a row that can't be dropped on top of\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`focused-cell` | Focused cell in the internal table\n`odd-row-cell` | Cell in an odd row\n`even-row-cell` | Cell in an even row\n`first-row-cell` | Cell in the first body row\n`last-row-cell` | Cell in the last body row\n`first-header-row-cell` | Cell in the first header row\n`first-footer-row-cell` | Cell in the first footer row\n`last-header-row-cell` | Cell in the last header row\n`last-footer-row-cell` | Cell in the last footer row\n`loading-row-cell` | Cell in a row that is waiting for data from data provider\n`selected-row-cell` | Cell in a selected row\n`expanded-row-cell` | Cell in an expanded row\n`details-opened-row-cell` | Cell in an row with details open\n`dragstart-row-cell` | Cell in a row that user started to drag (set for one frame)\n`dragover-above-row-cell` | Cell in a row that has another row dragged over above\n`dragover-below-row-cell` | Cell in a row that has another row dragged over below\n`dragover-on-top-row-cell` | Cell in a row that has another row dragged over on top\n`drag-disabled-row-cell` | Cell in a row that isn't available for dragging\n`drop-disabled-row-cell` | Cell in a row that can't be dropped on top of\n`frozen-cell` | Frozen cell in the internal table\n`frozen-to-end-cell` | Frozen to end cell in the internal table\n`last-frozen-cell` | Last frozen cell\n`first-frozen-to-end-cell` | First cell frozen to end\n`first-column-cell` | First visible cell on a row\n`last-column-cell` | Last visible cell on a row\n`reorder-allowed-cell` | Cell in a column where another column can be reordered\n`reorder-dragging-cell` | Cell in a column currently being reordered\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`frozen-to-end` | Cell frozen to end | cell\n`last-frozen` | Last frozen cell | cell\n`first-frozen-to-end` | First cell frozen to end | 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 starting to drag a row. The value is a number when dragging multiple rows | 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.",
|
|
1761
|
+
"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/24.1.0-alpha5/#/elements/vaadin-grid#property-items) property to visualize your data.\n\nUse the [`<vaadin-grid-column>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha5/#/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/24.1.0-alpha5/#/elements/vaadin-grid-column-group)\n- [`<vaadin-grid-filter>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha5/#/elements/vaadin-grid-filter)\n- [`<vaadin-grid-sorter>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha5/#/elements/vaadin-grid-sorter)\n- [`<vaadin-grid-selection-column>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha5/#/elements/vaadin-grid-selection-column)\n- [`<vaadin-grid-tree-toggle>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha5/#/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/24.1.0-alpha5/#/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/24.1.0-alpha5/#/elements/vaadin-grid#property-dataProvider) property\ndocumentation for the detailed data provider arguments description.\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`expanded-row` | Expanded row\n`selected-row` | Selected row\n`details-opened-row` | Row with details open\n`odd-row` | Odd row\n`even-row` | Even row\n`first-row` | The first body row\n`last-row` | The last body row\n`dragstart-row` | Set on the row for one frame when drag is starting.\n`dragover-above-row` | Set on the row when the a row is dragged over above\n`dragover-below-row` | Set on the row when the a row is dragged over below\n`dragover-on-top-row` | Set on the row when the a row is dragged over on top\n`drag-disabled-row` | Set to a row that isn't available for dragging\n`drop-disabled-row` | Set to a row that can't be dropped on top of\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`focused-cell` | Focused cell in the internal table\n`odd-row-cell` | Cell in an odd row\n`even-row-cell` | Cell in an even row\n`first-row-cell` | Cell in the first body row\n`last-row-cell` | Cell in the last body row\n`first-header-row-cell` | Cell in the first header row\n`first-footer-row-cell` | Cell in the first footer row\n`last-header-row-cell` | Cell in the last header row\n`last-footer-row-cell` | Cell in the last footer row\n`loading-row-cell` | Cell in a row that is waiting for data from data provider\n`selected-row-cell` | Cell in a selected row\n`expanded-row-cell` | Cell in an expanded row\n`details-opened-row-cell` | Cell in an row with details open\n`dragstart-row-cell` | Cell in a row that user started to drag (set for one frame)\n`dragover-above-row-cell` | Cell in a row that has another row dragged over above\n`dragover-below-row-cell` | Cell in a row that has another row dragged over below\n`dragover-on-top-row-cell` | Cell in a row that has another row dragged over on top\n`drag-disabled-row-cell` | Cell in a row that isn't available for dragging\n`drop-disabled-row-cell` | Cell in a row that can't be dropped on top of\n`frozen-cell` | Frozen cell in the internal table\n`frozen-to-end-cell` | Frozen to end cell in the internal table\n`last-frozen-cell` | Last frozen cell\n`first-frozen-to-end-cell` | First cell frozen to end\n`first-column-cell` | First visible cell on a row\n`last-column-cell` | Last visible cell on a row\n`reorder-allowed-cell` | Cell in a column where another column can be reordered\n`reorder-dragging-cell` | Cell in a column currently being reordered\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`frozen-to-end` | Cell frozen to end | cell\n`last-frozen` | Last frozen cell | cell\n`first-frozen-to-end` | First cell frozen to end | 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 starting to drag a row. The value is a number when dragging multiple rows | 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.",
|
|
1762
1762
|
"attributes": [
|
|
1763
1763
|
{
|
|
1764
1764
|
"name": "size",
|
|
@@ -1800,6 +1800,15 @@
|
|
|
1800
1800
|
]
|
|
1801
1801
|
}
|
|
1802
1802
|
},
|
|
1803
|
+
{
|
|
1804
|
+
"name": "column-rendering",
|
|
1805
|
+
"description": "Allows you to choose between modes for rendering columns in the grid:\n\n\"eager\" (default): All columns are rendered upfront, regardless of their visibility within the viewport.\nThis mode should generally be preferred, as it avoids the limitations imposed by the \"lazy\" mode.\nUse this mode unless the grid has a large number of columns and performance outweighs the limitations\nin priority.\n\n\"lazy\": Optimizes the rendering of cells when there are multiple columns in the grid by virtualizing\nhorizontal scrolling. In this mode, body cells are rendered only when their corresponding columns are\ninside the visible viewport.\n\nUsing \"lazy\" rendering should be used only if you're dealing with a large number of columns and performance\nis your highest priority. For most use cases, the default \"eager\" mode is recommended due to the\nlimitations imposed by the \"lazy\" mode.\n\nWhen using the \"lazy\" mode, keep the following limitations in mind:\n\n- Row Height: When only a number of columns are visible at once, the height of a row can only be that of\nthe highest cell currently visible on that row. Make sure each cell on a single row has the same height\nas all other cells on that row. If row cells have different heights, users may experience jumpiness when\nscrolling the grid horizontally as lazily rendered cells with different heights are scrolled into view.\n\n- Auto-width Columns: For the columns that are initially outside the visible viewport but still use auto-width,\nonly the header content is taken into account when calculating the column width because the body cells\nof the columns outside the viewport are not initially rendered.\n\n- Screen Reader Compatibility: Screen readers may not be able to associate the focused cells with the correct\nheaders when only a subset of the body cells on a row is rendered.\n\n- Keyboard Navigation: Tabbing through focusable elements inside the grid body may not work as expected because\nsome of the columns that would include focusable elements in the body cells may be outside the visible viewport\nand thus not rendered.",
|
|
1806
|
+
"value": {
|
|
1807
|
+
"type": [
|
|
1808
|
+
"ColumnRendering"
|
|
1809
|
+
]
|
|
1810
|
+
}
|
|
1811
|
+
},
|
|
1803
1812
|
{
|
|
1804
1813
|
"name": "multi-sort",
|
|
1805
1814
|
"description": "When `true`, all `<vaadin-grid-sorter>` are applied for sorting.",
|
|
@@ -1982,6 +1991,15 @@
|
|
|
1982
1991
|
]
|
|
1983
1992
|
}
|
|
1984
1993
|
},
|
|
1994
|
+
{
|
|
1995
|
+
"name": "columnRendering",
|
|
1996
|
+
"description": "Allows you to choose between modes for rendering columns in the grid:\n\n\"eager\" (default): All columns are rendered upfront, regardless of their visibility within the viewport.\nThis mode should generally be preferred, as it avoids the limitations imposed by the \"lazy\" mode.\nUse this mode unless the grid has a large number of columns and performance outweighs the limitations\nin priority.\n\n\"lazy\": Optimizes the rendering of cells when there are multiple columns in the grid by virtualizing\nhorizontal scrolling. In this mode, body cells are rendered only when their corresponding columns are\ninside the visible viewport.\n\nUsing \"lazy\" rendering should be used only if you're dealing with a large number of columns and performance\nis your highest priority. For most use cases, the default \"eager\" mode is recommended due to the\nlimitations imposed by the \"lazy\" mode.\n\nWhen using the \"lazy\" mode, keep the following limitations in mind:\n\n- Row Height: When only a number of columns are visible at once, the height of a row can only be that of\nthe highest cell currently visible on that row. Make sure each cell on a single row has the same height\nas all other cells on that row. If row cells have different heights, users may experience jumpiness when\nscrolling the grid horizontally as lazily rendered cells with different heights are scrolled into view.\n\n- Auto-width Columns: For the columns that are initially outside the visible viewport but still use auto-width,\nonly the header content is taken into account when calculating the column width because the body cells\nof the columns outside the viewport are not initially rendered.\n\n- Screen Reader Compatibility: Screen readers may not be able to associate the focused cells with the correct\nheaders when only a subset of the body cells on a row is rendered.\n\n- Keyboard Navigation: Tabbing through focusable elements inside the grid body may not work as expected because\nsome of the columns that would include focusable elements in the body cells may be outside the visible viewport\nand thus not rendered.",
|
|
1997
|
+
"value": {
|
|
1998
|
+
"type": [
|
|
1999
|
+
"ColumnRendering"
|
|
2000
|
+
]
|
|
2001
|
+
}
|
|
2002
|
+
},
|
|
1985
2003
|
{
|
|
1986
2004
|
"name": "selectedItems",
|
|
1987
2005
|
"description": "An array that contains the selected items.",
|
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": "24.1.0-
|
|
4
|
+
"version": "24.1.0-alpha5",
|
|
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/24.1.0-
|
|
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/24.1.0-alpha5/#/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/24.1.0-
|
|
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/24.1.0-alpha5/#/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
|
{
|
|
@@ -695,7 +695,7 @@
|
|
|
695
695
|
},
|
|
696
696
|
{
|
|
697
697
|
"name": "vaadin-grid",
|
|
698
|
-
"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/24.1.0-alpha4/#/elements/vaadin-grid#property-items) property to visualize your data.\n\nUse the [`<vaadin-grid-column>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha4/#/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/24.1.0-alpha4/#/elements/vaadin-grid-column-group)\n- [`<vaadin-grid-filter>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha4/#/elements/vaadin-grid-filter)\n- [`<vaadin-grid-sorter>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha4/#/elements/vaadin-grid-sorter)\n- [`<vaadin-grid-selection-column>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha4/#/elements/vaadin-grid-selection-column)\n- [`<vaadin-grid-tree-toggle>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha4/#/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/24.1.0-alpha4/#/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/24.1.0-alpha4/#/elements/vaadin-grid#property-dataProvider) property\ndocumentation for the detailed data provider arguments description.\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`expanded-row` | Expanded row\n`selected-row` | Selected row\n`details-opened-row` | Row with details open\n`odd-row` | Odd row\n`even-row` | Even row\n`first-row` | The first body row\n`last-row` | The last body row\n`dragstart-row` | Set on the row for one frame when drag is starting.\n`dragover-above-row` | Set on the row when the a row is dragged over above\n`dragover-below-row` | Set on the row when the a row is dragged over below\n`dragover-on-top-row` | Set on the row when the a row is dragged over on top\n`drag-disabled-row` | Set to a row that isn't available for dragging\n`drop-disabled-row` | Set to a row that can't be dropped on top of\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`focused-cell` | Focused cell in the internal table\n`odd-row-cell` | Cell in an odd row\n`even-row-cell` | Cell in an even row\n`first-row-cell` | Cell in the first body row\n`last-row-cell` | Cell in the last body row\n`first-header-row-cell` | Cell in the first header row\n`first-footer-row-cell` | Cell in the first footer row\n`last-header-row-cell` | Cell in the last header row\n`last-footer-row-cell` | Cell in the last footer row\n`loading-row-cell` | Cell in a row that is waiting for data from data provider\n`selected-row-cell` | Cell in a selected row\n`expanded-row-cell` | Cell in an expanded row\n`details-opened-row-cell` | Cell in an row with details open\n`dragstart-row-cell` | Cell in a row that user started to drag (set for one frame)\n`dragover-above-row-cell` | Cell in a row that has another row dragged over above\n`dragover-below-row-cell` | Cell in a row that has another row dragged over below\n`dragover-on-top-row-cell` | Cell in a row that has another row dragged over on top\n`drag-disabled-row-cell` | Cell in a row that isn't available for dragging\n`drop-disabled-row-cell` | Cell in a row that can't be dropped on top of\n`frozen-cell` | Frozen cell in the internal table\n`frozen-to-end-cell` | Frozen to end cell in the internal table\n`last-frozen-cell` | Last frozen cell\n`first-frozen-to-end-cell` | First cell frozen to end\n`first-column-cell` | First visible cell on a row\n`last-column-cell` | Last visible cell on a row\n`reorder-allowed-cell` | Cell in a column where another column can be reordered\n`reorder-dragging-cell` | Cell in a column currently being reordered\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`frozen-to-end` | Cell frozen to end | cell\n`last-frozen` | Last frozen cell | cell\n`first-frozen-to-end` | First cell frozen to end | 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 starting to drag a row. The value is a number when dragging multiple rows | 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.",
|
|
698
|
+
"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/24.1.0-alpha5/#/elements/vaadin-grid#property-items) property to visualize your data.\n\nUse the [`<vaadin-grid-column>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha5/#/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/24.1.0-alpha5/#/elements/vaadin-grid-column-group)\n- [`<vaadin-grid-filter>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha5/#/elements/vaadin-grid-filter)\n- [`<vaadin-grid-sorter>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha5/#/elements/vaadin-grid-sorter)\n- [`<vaadin-grid-selection-column>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha5/#/elements/vaadin-grid-selection-column)\n- [`<vaadin-grid-tree-toggle>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha5/#/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/24.1.0-alpha5/#/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/24.1.0-alpha5/#/elements/vaadin-grid#property-dataProvider) property\ndocumentation for the detailed data provider arguments description.\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`expanded-row` | Expanded row\n`selected-row` | Selected row\n`details-opened-row` | Row with details open\n`odd-row` | Odd row\n`even-row` | Even row\n`first-row` | The first body row\n`last-row` | The last body row\n`dragstart-row` | Set on the row for one frame when drag is starting.\n`dragover-above-row` | Set on the row when the a row is dragged over above\n`dragover-below-row` | Set on the row when the a row is dragged over below\n`dragover-on-top-row` | Set on the row when the a row is dragged over on top\n`drag-disabled-row` | Set to a row that isn't available for dragging\n`drop-disabled-row` | Set to a row that can't be dropped on top of\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`focused-cell` | Focused cell in the internal table\n`odd-row-cell` | Cell in an odd row\n`even-row-cell` | Cell in an even row\n`first-row-cell` | Cell in the first body row\n`last-row-cell` | Cell in the last body row\n`first-header-row-cell` | Cell in the first header row\n`first-footer-row-cell` | Cell in the first footer row\n`last-header-row-cell` | Cell in the last header row\n`last-footer-row-cell` | Cell in the last footer row\n`loading-row-cell` | Cell in a row that is waiting for data from data provider\n`selected-row-cell` | Cell in a selected row\n`expanded-row-cell` | Cell in an expanded row\n`details-opened-row-cell` | Cell in an row with details open\n`dragstart-row-cell` | Cell in a row that user started to drag (set for one frame)\n`dragover-above-row-cell` | Cell in a row that has another row dragged over above\n`dragover-below-row-cell` | Cell in a row that has another row dragged over below\n`dragover-on-top-row-cell` | Cell in a row that has another row dragged over on top\n`drag-disabled-row-cell` | Cell in a row that isn't available for dragging\n`drop-disabled-row-cell` | Cell in a row that can't be dropped on top of\n`frozen-cell` | Frozen cell in the internal table\n`frozen-to-end-cell` | Frozen to end cell in the internal table\n`last-frozen-cell` | Last frozen cell\n`first-frozen-to-end-cell` | First cell frozen to end\n`first-column-cell` | First visible cell on a row\n`last-column-cell` | Last visible cell on a row\n`reorder-allowed-cell` | Cell in a column where another column can be reordered\n`reorder-dragging-cell` | Cell in a column currently being reordered\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`frozen-to-end` | Cell frozen to end | cell\n`last-frozen` | Last frozen cell | cell\n`first-frozen-to-end` | First cell frozen to end | 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 starting to drag a row. The value is a number when dragging multiple rows | 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.",
|
|
699
699
|
"extension": true,
|
|
700
700
|
"attributes": [
|
|
701
701
|
{
|
|
@@ -803,6 +803,13 @@
|
|
|
803
803
|
"kind": "expression"
|
|
804
804
|
}
|
|
805
805
|
},
|
|
806
|
+
{
|
|
807
|
+
"name": ".columnRendering",
|
|
808
|
+
"description": "Allows you to choose between modes for rendering columns in the grid:\n\n\"eager\" (default): All columns are rendered upfront, regardless of their visibility within the viewport.\nThis mode should generally be preferred, as it avoids the limitations imposed by the \"lazy\" mode.\nUse this mode unless the grid has a large number of columns and performance outweighs the limitations\nin priority.\n\n\"lazy\": Optimizes the rendering of cells when there are multiple columns in the grid by virtualizing\nhorizontal scrolling. In this mode, body cells are rendered only when their corresponding columns are\ninside the visible viewport.\n\nUsing \"lazy\" rendering should be used only if you're dealing with a large number of columns and performance\nis your highest priority. For most use cases, the default \"eager\" mode is recommended due to the\nlimitations imposed by the \"lazy\" mode.\n\nWhen using the \"lazy\" mode, keep the following limitations in mind:\n\n- Row Height: When only a number of columns are visible at once, the height of a row can only be that of\nthe highest cell currently visible on that row. Make sure each cell on a single row has the same height\nas all other cells on that row. If row cells have different heights, users may experience jumpiness when\nscrolling the grid horizontally as lazily rendered cells with different heights are scrolled into view.\n\n- Auto-width Columns: For the columns that are initially outside the visible viewport but still use auto-width,\nonly the header content is taken into account when calculating the column width because the body cells\nof the columns outside the viewport are not initially rendered.\n\n- Screen Reader Compatibility: Screen readers may not be able to associate the focused cells with the correct\nheaders when only a subset of the body cells on a row is rendered.\n\n- Keyboard Navigation: Tabbing through focusable elements inside the grid body may not work as expected because\nsome of the columns that would include focusable elements in the body cells may be outside the visible viewport\nand thus not rendered.",
|
|
809
|
+
"value": {
|
|
810
|
+
"kind": "expression"
|
|
811
|
+
}
|
|
812
|
+
},
|
|
806
813
|
{
|
|
807
814
|
"name": ".selectedItems",
|
|
808
815
|
"description": "An array that contains the selected items.",
|