@progress/kendo-react-grid 5.11.0 → 5.11.1-dev.202302081554

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.
@@ -212,6 +212,10 @@ export interface GridProps extends KendoReactComponentBaseProps {
212
212
  * Defines the row height and forces an equal height to all rows ([see example]({% slug scrollmodes_grid %})).
213
213
  */
214
214
  rowHeight?: number;
215
+ /**
216
+ * Defines the detail row height and forces an equal height to all detail rows.
217
+ */
218
+ detailRowHeight?: number;
215
219
  /**
216
220
  * Specifies a React element that will be cloned and rendered inside the detail rows of the currently expanded items ([see example]({% slug hierarchy_grid %})). An item will be rendered as expanded if the value of its `expandField` is `true`.
217
221
  */
@@ -0,0 +1,27 @@
1
+ import { Page } from '../paging/Page';
2
+ import { SyntheticEvent, RefObject } from 'react';
3
+ import { RowHeightService } from '../VirtualScrollFixed';
4
+ /**
5
+ * @hidden
6
+ */
7
+ export interface VirtualScrollInterface {
8
+ get container(): HTMLDivElement | null;
9
+ askedSkip: number | undefined;
10
+ total: number;
11
+ reset: () => void;
12
+ table: HTMLTableElement | null;
13
+ tableBodyRef: RefObject<HTMLTableSectionElement>;
14
+ fixedScroll: boolean;
15
+ PageChange: ((event: Page, syntheticEvent: SyntheticEvent<any>) => void) | null;
16
+ realSkip: number;
17
+ pageSize: number;
18
+ scrollableVirtual: boolean;
19
+ propsSkip: number;
20
+ topCacheCount: number;
21
+ attendedSkip: number;
22
+ containerHeight: number;
23
+ containerRef: RefObject<HTMLDivElement>;
24
+ scrollHandler(e: SyntheticEvent<HTMLDivElement>): void;
25
+ rowHeightService?: RowHeightService;
26
+ tableTransform: string;
27
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -5,7 +5,7 @@ export var packageMetadata = {
5
5
  name: '@progress/kendo-react-grid',
6
6
  productName: 'KendoReact',
7
7
  productCodes: ['KENDOUIREACT', 'KENDOUICOMPLETE'],
8
- publishDate: 1675429179,
8
+ publishDate: 1675870734,
9
9
  version: '',
10
10
  licensingDocsUrl: 'https://www.telerik.com/kendo-react-ui/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning'
11
11
  };
@@ -93,6 +93,7 @@ export declare class Grid extends React.Component<GridProps, {}> {
93
93
  editField: PropTypes.Requireable<string>;
94
94
  scrollable: PropTypes.Requireable<string>;
95
95
  rowHeight: PropTypes.Requireable<number>;
96
+ detailRowHeight: PropTypes.Requireable<number>;
96
97
  detail: PropTypes.Requireable<any>;
97
98
  style: PropTypes.Requireable<object>;
98
99
  onDataStateChange: PropTypes.Requireable<(...args: any[]) => any>;
@@ -111,6 +112,7 @@ export declare class Grid extends React.Component<GridProps, {}> {
111
112
  private contextStateRef;
112
113
  private navigationStateRef;
113
114
  private _data;
115
+ private _slicedData;
114
116
  private wrapperScrollTop;
115
117
  /**
116
118
  * A getter of the current columns. Gets the current column width or current columns, or any other [`GridColumnProps`]({% slug api_grid_gridcolumnprops %}) for each defined column. Can be used on each Grid instance. To obtain the instance of the rendered Grid, use the `ref` callback. The following example demonstrates how to reorder the columns by dragging their handlers and check the properties afterwards. You can check the result in the browser console.
@@ -160,12 +162,15 @@ export declare class Grid extends React.Component<GridProps, {}> {
160
162
  private headerElementRef;
161
163
  private _element;
162
164
  private tableElement;
165
+ private containerRef;
166
+ private tableBodyRef;
163
167
  private vs;
164
168
  private columnResize;
165
169
  private _footer;
166
170
  private forceUpdateTimeout;
167
171
  private isRtl;
168
172
  private _gridId;
173
+ private _prevTotal;
169
174
  private get _header();
170
175
  constructor(props: GridProps);
171
176
  /**
@@ -202,6 +207,9 @@ export declare class Grid extends React.Component<GridProps, {}> {
202
207
  * @hidden
203
208
  */
204
209
  render(): JSX.Element;
210
+ private getVirtualScroll;
211
+ private isAllData;
212
+ private initializeVirtualization;
205
213
  private scrollHandler;
206
214
  private onKeyDown;
207
215
  private onFocus;
@@ -223,6 +231,8 @@ export declare class Grid extends React.Component<GridProps, {}> {
223
231
  private columnToGroup;
224
232
  private resetTableWidth;
225
233
  private onResize;
234
+ private flatData;
235
+ private rowHeightService;
226
236
  private childrenToArray;
227
237
  private readColumns;
228
238
  private mapColumns;
package/dist/npm/Grid.js CHANGED
@@ -49,6 +49,7 @@ var FilterRow_1 = require("./header/FilterRow");
49
49
  var GroupPanel_1 = require("./header/GroupPanel");
50
50
  var Footer_1 = require("./footer/Footer");
51
51
  var VirtualScroll_1 = require("./VirtualScroll");
52
+ var VirtualScrollFixed_1 = require("./VirtualScrollFixed");
52
53
  var ColumnResize_1 = require("./drag/ColumnResize");
53
54
  var CommonDragLogic_1 = require("./drag/CommonDragLogic");
54
55
  var index_1 = require("./utils/index");
@@ -106,15 +107,19 @@ var Grid = /** @class */ (function (_super) {
106
107
  _this.contextStateRef = { current: undefined };
107
108
  _this.navigationStateRef = { current: undefined };
108
109
  _this._data = [];
110
+ _this._slicedData = undefined;
109
111
  _this.wrapperScrollTop = 0;
110
112
  _this.headerRef = React.createRef();
111
113
  _this.headerElementRef = React.createRef();
112
114
  _this._element = null;
113
115
  _this.tableElement = null;
116
+ _this.containerRef = React.createRef();
117
+ _this.tableBodyRef = React.createRef();
114
118
  _this._footer = null;
115
119
  _this.forceUpdateTimeout = undefined;
116
120
  _this.isRtl = false;
117
121
  _this._gridId = (0, kendo_react_common_1.guid)();
122
+ _this._prevTotal = undefined;
118
123
  /**
119
124
  * Method to allow the scroll to be set to a specific row index.
120
125
  *
@@ -146,11 +151,77 @@ var Grid = /** @class */ (function (_super) {
146
151
  _this.fitColumns = function (columnIds) {
147
152
  _this.columnResize.dblClickHandler(null, columnIds);
148
153
  };
154
+ _this.getVirtualScroll = function (props) {
155
+ var rowHeight = props.rowHeight, detailRowHeight = props.detailRowHeight, detail = props.detail, expandField = props.expandField, groupable = props.groupable;
156
+ var hasAllData = _this.isAllData();
157
+ var hasRowHeight = rowHeight !== undefined && rowHeight > 0;
158
+ var hasDetailRowHeight = detailRowHeight !== undefined && detailRowHeight > 0;
159
+ var isGroupable = groupable === true || (typeof groupable === 'object' && groupable.enabled !== false);
160
+ var hasDetails = Boolean(detail && expandField);
161
+ if (!hasRowHeight ||
162
+ (isGroupable && !hasAllData) ||
163
+ (hasDetails && (!hasDetailRowHeight || !hasAllData))) {
164
+ return VirtualScroll_1.VirtualScroll;
165
+ }
166
+ return VirtualScrollFixed_1.VirtualScrollFixed;
167
+ };
168
+ _this.isAllData = function () {
169
+ var _a = _this.props, data = _a.data, total = _a.total;
170
+ if (Array.isArray(data)) {
171
+ return data.length === total;
172
+ }
173
+ else if (data) {
174
+ return total === data.total;
175
+ }
176
+ return false;
177
+ };
178
+ _this.initializeVirtualization = function (total, groupable) {
179
+ if (_this.props.total !== _this._prevTotal || (_this.props.scrollable === 'virtual') !== _this.vs.scrollableVirtual) {
180
+ _this.vs.reset();
181
+ var VS = _this.getVirtualScroll(_this.props);
182
+ _this.vs = new VS(groupable || _this.props.rowHeight === undefined || _this.props.rowHeight === 0);
183
+ }
184
+ _this.vs.fixedScroll = _this.props.fixedScroll || false;
185
+ _this.vs.PageChange = _this.pageChange;
186
+ _this.vs.realSkip = _this.props.skip || 0;
187
+ _this.vs.pageSize = (_this.props.take !== undefined ? _this.props.take : _this.props.pageSize) || 0;
188
+ _this.vs.scrollableVirtual = (_this.props.scrollable === 'virtual');
189
+ _this.vs.total = total;
190
+ _this.vs.propsSkip = (_this.props.skip || 0) + (_this.props.scrollable === 'virtual' ?
191
+ _this.vs.topCacheCount + (_this.vs.attendedSkip - (_this.props.skip || 0)) : 0);
192
+ if (_this.props.rowHeight !== undefined && _this.props.rowHeight > 0 && !groupable) {
193
+ var containerHeight = _this.props.rowHeight * total;
194
+ _this.vs.containerHeight = index_1.firefox ? Math.min(index_1.firefoxMaxHeight, containerHeight) : containerHeight;
195
+ }
196
+ else {
197
+ _this.vs.containerHeight = 1533915;
198
+ }
199
+ _this.vs.containerRef = _this.containerRef;
200
+ _this.vs.tableBodyRef = _this.tableBodyRef;
201
+ _this.vs.table = _this.tableElement;
202
+ _this._slicedData = undefined;
203
+ if (_this.vs instanceof VirtualScrollFixed_1.VirtualScrollFixed) {
204
+ var _a = _this.props, _b = _a.rowHeight, rowHeight = _b === void 0 ? 0 : _b, detail = _a.detail, expandField = _a.expandField;
205
+ var _c = _this.props.detailRowHeight, detailRowHeight = _c === void 0 ? 0 : _c;
206
+ detailRowHeight = Boolean(detail && expandField) ? detailRowHeight : rowHeight;
207
+ if (_this.isAllData()) {
208
+ _this.vs.total = _this._data.length;
209
+ _this._slicedData = _this._data.slice(_this.vs.realSkip, _this.vs.realSkip + _this.vs.pageSize);
210
+ _this.vs.rowHeightService = _this.rowHeightService(_this.vs, _this._data.length, rowHeight, detailRowHeight, _this._data);
211
+ }
212
+ else {
213
+ _this.vs.rowHeightService = new VirtualScrollFixed_1.RowHeightService(total, rowHeight, detailRowHeight);
214
+ }
215
+ var containerHeight = _this.vs.rowHeightService.totalHeight();
216
+ _this.vs.containerHeight = index_1.firefox ? Math.min(index_1.firefoxMaxHeight, containerHeight) : containerHeight;
217
+ }
218
+ };
149
219
  _this.scrollHandler = function (event) {
150
220
  if (event.target !== event.currentTarget) {
151
221
  return;
152
222
  }
153
223
  clearTimeout(_this.forceUpdateTimeout);
224
+ _this.vs.table = _this.tableElement;
154
225
  var scrollLeft = event.currentTarget.scrollLeft;
155
226
  var scrollTop = event.currentTarget.scrollTop;
156
227
  if (_this.props.columnVirtualization && (!_this.vs.scrollableVirtual || scrollTop === _this.wrapperScrollTop)) {
@@ -265,6 +336,14 @@ var Grid = /** @class */ (function (_super) {
265
336
  });
266
337
  }
267
338
  };
339
+ _this.flatData = (0, kendo_react_common_1.memoizeOne)(function (propsData, groupingFooter, skip, group, expandField, _filter, _sort) {
340
+ var flattedData = [];
341
+ var resolvedGroupsCount = (0, index_1.flatData)(flattedData, propsData, groupingFooter, { index: skip }, group !== undefined, expandField);
342
+ return { flattedData: flattedData, resolvedGroupsCount: resolvedGroupsCount };
343
+ });
344
+ _this.rowHeightService = (0, kendo_react_common_1.memoizeOne)(function (_vs, total, rowHeight, detailRowHeight, data) {
345
+ return new VirtualScrollFixed_1.RowHeightService(total, rowHeight, detailRowHeight, data);
346
+ });
268
347
  _this.childrenToArray = (0, kendo_react_common_1.memoizeOne)(function (children) {
269
348
  return React.Children.toArray(children);
270
349
  });
@@ -314,7 +393,7 @@ var Grid = /** @class */ (function (_super) {
314
393
  columns.slice(columnIndexOffset).forEach(function (c) { return c.parentIndex >= 0 && (c.parentIndex += columnIndexOffset); });
315
394
  });
316
395
  _this.getHeaderRow = (0, kendo_react_common_1.memoizeOne)(function (sort, sortable, group, groupable, filter, filterable, filterOperators, headerCellRender, columnMenu, columns, columnsMap) {
317
- return (React.createElement(HeaderRow_1.HeaderRow, { sort: sort, sortable: sortable, sortChange: _this.sortChange, group: group || [], groupable: groupable, groupChange: _this.groupChange, filter: filter, filterable: filterable, filterOperators: filterOperators, filterChange: _this.filterChange, columnMenu: columnMenu, selectionChange: _this.onHeaderSelectionChange, columns: columns, columnResize: _this.columnResize, pressHandler: _this.dragLogic.pressHandler, dragHandler: _this.dragLogic.dragHandler, releaseHandler: _this.dragLogic.releaseHandler, columnsMap: columnsMap, cellRender: headerCellRender, isRtl: _this.isRtl, dragClue: _this.dragLogic.dragClueRef, headerRef: _this.headerElementRef, containerRef: _this.vs.containerRef }));
396
+ return (React.createElement(HeaderRow_1.HeaderRow, { sort: sort, sortable: sortable, sortChange: _this.sortChange, group: group || [], groupable: groupable, groupChange: _this.groupChange, filter: filter, filterable: filterable, filterOperators: filterOperators, filterChange: _this.filterChange, columnMenu: columnMenu, selectionChange: _this.onHeaderSelectionChange, columns: columns, columnResize: _this.columnResize, pressHandler: _this.dragLogic.pressHandler, dragHandler: _this.dragLogic.dragHandler, releaseHandler: _this.dragLogic.releaseHandler, columnsMap: columnsMap, cellRender: headerCellRender, isRtl: _this.isRtl, dragClue: _this.dragLogic.dragClueRef, headerRef: _this.headerElementRef, containerRef: _this.containerRef }));
318
397
  });
319
398
  _this.resolveTitle = function (field) {
320
399
  var column = _this._columns.find(function (c) { return c.field === field; });
@@ -327,7 +406,8 @@ var Grid = /** @class */ (function (_super) {
327
406
  (0, kendo_react_common_2.validatePackage)(package_metadata_1.packageMetadata);
328
407
  var groupable = _this.props.groupable === true ||
329
408
  (typeof _this.props.groupable === 'object') && _this.props.groupable.enabled !== false;
330
- _this.vs = new VirtualScroll_1.VirtualScroll(groupable || props.rowHeight === undefined || props.rowHeight === 0);
409
+ var VS = _this.getVirtualScroll(props);
410
+ _this.vs = new VS(groupable || props.rowHeight === undefined || props.rowHeight === 0);
331
411
  _this.dragLogic = new CommonDragLogic_1.CommonDragLogic(_this.columnReorder.bind(_this), _this.groupReorder.bind(_this), _this.columnToGroup.bind(_this));
332
412
  _this.columnResize = new ColumnResize_1.ColumnResize(_this.onResize);
333
413
  kendo_react_data_tools_1.tableKeyboardNavigation.onConstructor({
@@ -418,9 +498,11 @@ var Grid = /** @class */ (function (_super) {
418
498
  * @hidden
419
499
  */
420
500
  Grid.prototype.componentDidMount = function () {
501
+ this.resetTableWidth();
421
502
  (0, kendo_react_common_1.setScrollbarWidth)();
422
503
  var rtl = (0, kendo_react_data_tools_1.isRtl)(this.element);
423
504
  this.isRtl = rtl;
505
+ this._prevTotal = this.props.total;
424
506
  kendo_react_data_tools_1.tableKeyboardNavigation.onComponentDidMount({
425
507
  scope: this.element || undefined,
426
508
  contextStateRef: this.contextStateRef,
@@ -446,6 +528,11 @@ var Grid = /** @class */ (function (_super) {
446
528
  */
447
529
  Grid.prototype.componentDidUpdate = function () {
448
530
  (0, kendo_react_common_1.setScrollbarWidth)();
531
+ this._prevTotal = this.props.total;
532
+ if (this.vs.tableTransform && this.vs.table) {
533
+ this.vs.table.style.transform = this.vs.tableTransform;
534
+ this.vs.tableTransform = '';
535
+ }
449
536
  kendo_react_data_tools_1.tableKeyboardNavigation.onComponentDidUpdate({
450
537
  scope: this.element || undefined,
451
538
  contextStateRef: this.contextStateRef,
@@ -475,35 +562,16 @@ var Grid = /** @class */ (function (_super) {
475
562
  propsData = this.props.data.data;
476
563
  total = total || this.props.data.total;
477
564
  }
565
+ var groupingFooter = (typeof this.props.groupable === 'object') && this.props.groupable.footer || 'none';
566
+ var _d = this.flatData(propsData, groupingFooter, this.props.skip || 0, this.props.group, this.props.expandField, this.props.filter, this.props.sort), resolvedGroupsCount = _d.resolvedGroupsCount, flattedData = _d.flattedData;
567
+ this._data = flattedData;
478
568
  var groupable = this.props.groupable === true ||
479
569
  (typeof this.props.groupable === 'object') && this.props.groupable.enabled !== false;
480
570
  this.columnResize.resizable = this.props.resizable || false;
481
571
  this.dragLogic.reorderable = this.props.reorderable || false;
482
572
  this.dragLogic.groupable = groupable;
483
573
  var tableUserSelect = this.props.selectable && this.props.selectable.drag ? 'none' : undefined;
484
- if (total !== this.vs.total || (this.props.scrollable === 'virtual') !== this.vs.scrollableVirtual) {
485
- this.vs.reset();
486
- this.vs = new VirtualScroll_1.VirtualScroll(groupable || this.props.rowHeight === undefined || this.props.rowHeight === 0);
487
- this.vs.table = this.tableElement;
488
- }
489
- this.vs.fixedScroll = this.props.fixedScroll || false;
490
- this.vs.PageChange = this.pageChange;
491
- this.vs.realSkip = this.props.skip || 0;
492
- this.vs.pageSize = (this.props.take !== undefined ? this.props.take : this.props.pageSize) || 0;
493
- this.vs.scrollableVirtual = (this.props.scrollable === 'virtual');
494
- this.vs.total = total;
495
- this.vs.propsSkip = (this.props.skip || 0) + (this.props.scrollable === 'virtual' ?
496
- this.vs.topCacheCount + (this.vs.attendedSkip - (this.props.skip || 0)) : 0);
497
- if (this.props.rowHeight !== undefined && this.props.rowHeight > 0 && !groupable) {
498
- var containerHeight = this.props.rowHeight * total;
499
- this.vs.containerHeight = index_1.firefox ? Math.min(index_1.firefoxMaxHeight, containerHeight) : containerHeight;
500
- }
501
- else {
502
- this.vs.containerHeight = 1533915;
503
- }
504
- var groupingFooter = (typeof this.props.groupable === 'object') && this.props.groupable.footer || 'none';
505
- this._data = [];
506
- var resolvedGroupsCount = (0, index_1.flatData)(this._data, propsData, groupingFooter, { index: this.props.skip || 0 }, this.props.group !== undefined, this.props.expandField);
574
+ this.initializeVirtualization(total, groupable);
507
575
  var children = this.childrenToArray(this.props.children);
508
576
  this.initColumns(children, resolvedGroupsCount);
509
577
  var toolbar = children.filter(function (child) { return child && child.type &&
@@ -512,17 +580,17 @@ var Grid = /** @class */ (function (_super) {
512
580
  child.type.displayName === 'KendoReactGridNoRecords'; });
513
581
  var leafColumns = this._columns.filter(function (c) { return c.children.length === 0; });
514
582
  var groupingPanel = groupable && (React.createElement(GroupPanel_1.GroupPanel, { group: this.props.group || [], groupChange: this.groupChange, pressHandler: this.dragLogic.pressHandler, dragHandler: this.dragLogic.dragHandler, releaseHandler: this.dragLogic.releaseHandler, refCallback: this.dragLogic.refGroupPanelDiv, resolveTitle: this.resolveTitle }));
515
- var _d = this.props, sort = _d.sort, sortable = _d.sortable, group = _d.group, filter = _d.filter, filterable = _d.filterable, _e = _d.filterOperators, filterOperators = _e === void 0 ? filterCommon_1.operators : _e, headerCellRender = _d.headerCellRender, columnMenu = _d.columnMenu;
583
+ var _e = this.props, sort = _e.sort, sortable = _e.sortable, group = _e.group, filter = _e.filter, filterable = _e.filterable, _f = _e.filterOperators, filterOperators = _f === void 0 ? filterCommon_1.operators : _f, headerCellRender = _e.headerCellRender, columnMenu = _e.columnMenu;
516
584
  var header = (React.createElement(Header_1.Header, { size: this.props.size, columnResize: this.columnResize, staticHeaders: this.props.scrollable !== 'none', scrollableDataElement: function () { return _this.vs.container; }, draggable: this.props.reorderable || groupable, ref: this.headerRef, elemRef: this.headerElementRef, headerRow: this.getHeaderRow(sort, sortable, group, groupable, filter, filterable, filterOperators, headerCellRender, columnMenu, this._columns, this._columnsMap), filterRow: this.props.filterable && React.createElement(FilterRow_1.FilterRow, { size: this.props.size, columns: this._columns, filter: this.props.filter, filterOperators: this.props.filterOperators || filterCommon_1.operators, filterChange: this.filterChange, sort: this.props.sort, cellRender: this.props.filterCellRender, isRtl: this.isRtl, ariaRowIndex: this._columnsMap.length + 1 }) || undefined, cols: leafColumns.map(function (column, index) { return (React.createElement("col", { key: index.toString(), width: column.width !== undefined ?
517
585
  Math.floor(parseFloat(column.width.toString())) + 'px' : undefined })); }) }));
518
586
  var scrollLeft = this.vs && this.vs.container && this.vs.container.scrollLeft || 0;
519
587
  var tableWidth = parseFloat(((this.props.style || {}).width || '').toString());
520
- var _f = (0, kendo_react_data_tools_1.tableColumnsVirtualization)({
588
+ var _g = (0, kendo_react_data_tools_1.tableColumnsVirtualization)({
521
589
  enabled: this.props.columnVirtualization,
522
590
  columns: leafColumns,
523
591
  tableViewPortWidth: tableWidth,
524
592
  scrollLeft: scrollLeft
525
- }), colSpans = _f.colSpans, isColHidden = _f.hiddenColumns;
593
+ }), colSpans = _g.colSpans, isColHidden = _g.hiddenColumns;
526
594
  var dataRow = function (item, rowId, rowDataIndex) {
527
595
  var isInEdit = false;
528
596
  var selectedValue = _this.props.selectedField ? (0, index_1.getNestedValue)(_this.props.selectedField, item.dataItem) : undefined;
@@ -575,21 +643,21 @@ var Grid = /** @class */ (function (_super) {
575
643
  var hidden = function (index) {
576
644
  return (index >= _this._data.length - hiddenRows);
577
645
  };
578
- var absoluteDataIndex = this.vs.propsSkip || 0;
646
+ var absoluteDataIndex = this.vs.realSkip || 0;
579
647
  var body = [];
580
648
  var rowIndexStart = this._columnsMap.length + (this.props.filterable ? 1 : 0) + 1;
581
649
  var currentAriaRowIndex = 0;
582
650
  if (this._data.length) {
583
651
  var dataIndex_1 = -1;
584
652
  var detailRowCount_1 = 0;
585
- this._data.forEach(function (item, rowIndex) {
653
+ (this._slicedData || this._data).forEach(function (item, rowIndex) {
586
654
  if (item.rowType === 'data') {
587
655
  absoluteDataIndex++;
588
656
  dataIndex_1++;
589
657
  }
590
658
  var isAlt = absoluteDataIndex % 2 === 0;
591
659
  var dataItemKey = _this.props.dataItemKey && (0, kendo_react_common_1.getter)(_this.props.dataItemKey)(item.dataItem);
592
- var absoluteIndex = rowIndex + (_this.vs.propsSkip || 0);
660
+ var absoluteIndex = rowIndex + (_this.vs.realSkip || 0);
593
661
  var rowId = dataItemKey ? dataItemKey : 'ai' + absoluteIndex;
594
662
  var detailRowId = rowId + '_1';
595
663
  var gridRow = dataRow(item, rowId, dataIndex_1);
@@ -601,7 +669,7 @@ var Grid = /** @class */ (function (_super) {
601
669
  - (_this.props.group ? _this.props.group.length : 0)) || 1;
602
670
  detailRowCount_1++;
603
671
  currentAriaRowIndex = absoluteIndex + rowIndexStart + detailRowCount_1;
604
- body.push((React.createElement("tr", { key: detailRowId, className: (0, kendo_react_common_1.classNames)('k-table-row', isAlt ? 'k-detail-row k-table-alt-row k-alt' : 'k-detail-row'), style: { visibility: hidden(rowIndex) ? 'hidden' : '' }, role: "row", "aria-rowindex": currentAriaRowIndex },
672
+ body.push((React.createElement("tr", { key: detailRowId, className: (0, kendo_react_common_1.classNames)('k-table-row', isAlt ? 'k-detail-row k-table-alt-row k-alt' : 'k-detail-row'), style: { visibility: hidden(rowIndex) ? 'hidden' : '', height: _this.props.detailRowHeight }, role: "row", "aria-rowindex": currentAriaRowIndex },
605
673
  _this.props.group && _this.props.group.map(function (gr, idx) {
606
674
  var _a;
607
675
  var columnStyle = (_a = gridRow === null || gridRow === void 0 ? void 0 : gridRow.row[idx]) === null || _a === void 0 ? void 0 : _a.props.style;
@@ -645,9 +713,7 @@ var Grid = /** @class */ (function (_super) {
645
713
  toolbar,
646
714
  groupingPanel,
647
715
  React.createElement(kendo_react_data_tools_1.TableSelection, { selectable: this.props.selectable, onRelease: this.selectionRelease, childRef: function (table) {
648
- _this.vs.table = table;
649
716
  _this.tableElement = table;
650
- _this.resetTableWidth();
651
717
  } },
652
718
  React.createElement("table", { style: { userSelect: tableUserSelect, display: tableDisplay } },
653
719
  colGroups,
@@ -674,16 +740,14 @@ var Grid = /** @class */ (function (_super) {
674
740
  _b['k-grid-virtual'] = this.props.scrollable === 'virtual',
675
741
  _b), this.props.className), ref: function (el) {
676
742
  _this._element = el;
677
- _this.resetTableWidth();
678
743
  }, role: "grid", "aria-colcount": leafColumns.length, "aria-rowcount": total, "aria-label": this.props.ariaLabel, onKeyDown: this.onKeyDown, onFocus: this.onFocus }, kendo_react_data_tools_1.tableKeyboardNavigationScopeAttributes),
679
744
  toolbar,
680
745
  groupingPanel,
681
746
  header,
682
747
  React.createElement("div", { className: "k-grid-container", role: "presentation" },
683
- React.createElement("div", { ref: this.vs.containerRef, className: "k-grid-content k-virtual-content", onScroll: this.scrollHandler, role: "presentation" },
748
+ React.createElement("div", { ref: this.containerRef, className: "k-grid-content k-virtual-content", onScroll: this.scrollHandler, role: "presentation" },
684
749
  React.createElement("div", { className: 'k-grid-table-wrap', role: "presentation" },
685
750
  React.createElement(kendo_react_data_tools_1.TableSelection, { selectable: this.props.selectable, onRelease: this.selectionRelease, childRef: function (table) {
686
- _this.vs.table = table;
687
751
  _this.tableElement = table;
688
752
  } },
689
753
  React.createElement("table", { className: (0, kendo_react_common_1.classNames)('k-table k-grid-table', (_c = {
@@ -692,9 +756,7 @@ var Grid = /** @class */ (function (_super) {
692
756
  _c["k-table-".concat(kendo_react_common_1.kendoThemeMaps.sizeMap[this.props.size] || this.props.size)] = this.props.size,
693
757
  _c), this.props.className), role: "presentation", style: { userSelect: tableUserSelect, display: tableDisplay } },
694
758
  colGroups,
695
- React.createElement("tbody", __assign({ className: 'k-table-tbody', ref: function (tableBody) {
696
- _this.vs.tableBody = tableBody;
697
- }, role: 'rowgroup' }, kendo_react_data_tools_1.tableKeyboardNavigationBodyAttributes), body)))),
759
+ React.createElement("tbody", __assign({ className: 'k-table-tbody', ref: this.tableBodyRef, role: 'rowgroup' }, kendo_react_data_tools_1.tableKeyboardNavigationBodyAttributes), body)))),
698
760
  React.createElement("div", { className: "k-height-container", role: "presentation" },
699
761
  React.createElement("div", { style: this.props.scrollable === 'virtual' ?
700
762
  { 'height': (this.vs.containerHeight) + 'px' } : {} })))),
@@ -786,8 +848,8 @@ var Grid = /** @class */ (function (_super) {
786
848
  if (this._footer) {
787
849
  this._footer.setWidth(totalWidth);
788
850
  }
789
- if (this.vs.table) {
790
- this.vs.table.style.width = totalWidth + 'px';
851
+ if (this.tableElement) {
852
+ this.tableElement.style.width = totalWidth + 'px';
791
853
  }
792
854
  };
793
855
  Grid.prototype.initColumns = function (children, groupCount) {
@@ -888,6 +950,7 @@ var Grid = /** @class */ (function (_super) {
888
950
  editField: PropTypes.string,
889
951
  scrollable: PropTypes.oneOf(['none', 'scrollable', 'virtual']),
890
952
  rowHeight: PropTypes.number,
953
+ detailRowHeight: PropTypes.number,
891
954
  detail: PropTypes.any,
892
955
  style: PropTypes.object,
893
956
  onDataStateChange: PropTypes.func,
@@ -1,9 +1,11 @@
1
1
  import { Page } from './paging/Page';
2
2
  import * as React from 'react';
3
+ import { VirtualScrollInterface } from './interfaces/VirtualScrollInterface';
4
+ import { RowHeightService } from './VirtualScrollFixed';
3
5
  /**
4
6
  * @hidden
5
7
  */
6
- export declare class VirtualScroll {
8
+ export declare class VirtualScroll implements VirtualScrollInterface {
7
9
  table: HTMLTableElement | null;
8
10
  containerHeight: number;
9
11
  topCacheCount: number;
@@ -14,16 +16,18 @@ export declare class VirtualScroll {
14
16
  realSkip: number;
15
17
  pageSize: number;
16
18
  PageChange: ((event: Page, syntheticEvent: React.SyntheticEvent<any>) => void) | null;
17
- tableBody: HTMLTableSectionElement | null;
18
- heightContainer: null;
19
+ tableBodyRef: React.RefObject<HTMLTableSectionElement>;
19
20
  fixedScroll: boolean;
20
21
  askedSkip: number | undefined;
21
22
  containerRef: React.RefObject<HTMLDivElement>;
23
+ tableTransform: string;
22
24
  get container(): HTMLDivElement | null;
23
25
  private prevScrollPos;
24
26
  private tableTranslate;
25
27
  private scrollSyncing;
28
+ private reactVersion;
26
29
  constructor(cached: boolean);
30
+ rowHeightService?: RowHeightService;
27
31
  /**
28
32
  * @return - The row heights in an array.
29
33
  */
@@ -32,7 +36,7 @@ export declare class VirtualScroll {
32
36
  acc: number;
33
37
  }>;
34
38
  changePage(skip: number, e: React.SyntheticEvent<HTMLDivElement>): void;
35
- translate(dY: number): void;
39
+ translate(dY: number, forceSet?: boolean): void;
36
40
  reset(): void;
37
41
  localScrollUp(e: React.SyntheticEvent<HTMLDivElement>): void;
38
42
  localScrollDown(e: React.SyntheticEvent<HTMLDivElement>): void;
@@ -18,14 +18,15 @@ var VirtualScroll = /** @class */ (function () {
18
18
  this.realSkip = 0;
19
19
  this.pageSize = 0;
20
20
  this.PageChange = null;
21
- this.tableBody = null;
22
- this.heightContainer = null;
21
+ this.tableBodyRef = React.createRef();
23
22
  this.fixedScroll = false;
24
23
  this.askedSkip = undefined;
25
24
  this.containerRef = React.createRef();
25
+ this.tableTransform = '';
26
26
  this.prevScrollPos = 0;
27
27
  this.tableTranslate = 0;
28
28
  this.scrollSyncing = false;
29
+ this.reactVersion = Number.parseFloat(React.version);
29
30
  this.topItems = function (heights, skipTopBuffer) {
30
31
  if (!_this.container || skipTopBuffer) {
31
32
  return { topItemsCount: 0, topItemsHeight: 0 };
@@ -68,7 +69,7 @@ var VirtualScroll = /** @class */ (function () {
68
69
  */
69
70
  get: function () {
70
71
  var result = [];
71
- var allRows = this.tableBody && this.tableBody.children || [];
72
+ var allRows = this.tableBodyRef.current && this.tableBodyRef.current.children || [];
72
73
  var accumulate = 0;
73
74
  for (var i = 0; i < allRows.length; i++) {
74
75
  if (allRows[i].className.indexOf('k-grouping-row') > -1) {
@@ -100,10 +101,15 @@ var VirtualScroll = /** @class */ (function () {
100
101
  }, e);
101
102
  }
102
103
  };
103
- VirtualScroll.prototype.translate = function (dY) {
104
+ VirtualScroll.prototype.translate = function (dY, forceSet) {
104
105
  this.tableTranslate = dY;
105
106
  if (this.scrollableVirtual && this.table) {
106
- this.table.style.transform = 'translateY(' + dY + 'px)';
107
+ if (this.reactVersion <= 17 || forceSet) {
108
+ this.table.style.transform = 'translateY(' + dY + 'px)';
109
+ }
110
+ else {
111
+ this.tableTransform = 'translateY(' + dY + 'px)';
112
+ }
107
113
  }
108
114
  };
109
115
  VirtualScroll.prototype.reset = function () {
@@ -114,7 +120,7 @@ var VirtualScroll = /** @class */ (function () {
114
120
  if (this.container) {
115
121
  this.container.scrollTop = 0;
116
122
  }
117
- this.translate(0);
123
+ this.translate(0, true);
118
124
  };
119
125
  VirtualScroll.prototype.localScrollUp = function (e) {
120
126
  if (!this.container) {
@@ -0,0 +1,49 @@
1
+ import { Page } from './paging/Page';
2
+ import * as React from 'react';
3
+ import { VirtualScrollInterface } from './interfaces/VirtualScrollInterface';
4
+ import { DataItemWrapper } from './utils';
5
+ /**
6
+ * @hidden
7
+ */
8
+ export declare class RowHeightService {
9
+ private total;
10
+ private offsets;
11
+ private heights;
12
+ constructor(total: number, rowHeight: number, detailRowHeight: number, data?: DataItemWrapper[]);
13
+ height(rowIndex: number): number;
14
+ index(position: number): number | undefined;
15
+ offset(rowIndex: number): number;
16
+ totalHeight(): number;
17
+ }
18
+ /**
19
+ * @hidden
20
+ */
21
+ export declare class VirtualScrollFixed implements VirtualScrollInterface {
22
+ table: HTMLTableElement | null;
23
+ containerHeight: number;
24
+ topCacheCount: number;
25
+ attendedSkip: number;
26
+ propsSkip: number;
27
+ total: number;
28
+ scrollableVirtual: boolean;
29
+ realSkip: number;
30
+ pageSize: number;
31
+ PageChange: ((event: Page, syntheticEvent: React.SyntheticEvent<any>) => void) | null;
32
+ tableBodyRef: React.RefObject<HTMLTableSectionElement>;
33
+ fixedScroll: boolean;
34
+ askedSkip: number | undefined;
35
+ containerRef: React.RefObject<HTMLDivElement>;
36
+ tableTransform: string;
37
+ rowHeightService?: RowHeightService;
38
+ private scrollSyncing;
39
+ private lastLoaded;
40
+ private firstLoaded;
41
+ private lastScrollTop;
42
+ private reactVersion;
43
+ get container(): HTMLDivElement | null;
44
+ constructor(_cached: boolean);
45
+ translate(dY: number, forceSet?: boolean): void;
46
+ changePage(skip: number, e: React.SyntheticEvent<HTMLDivElement>): void;
47
+ reset(): void;
48
+ scrollHandler(e: React.SyntheticEvent<HTMLDivElement>): void;
49
+ }