Skip to content

Commit

Permalink
fix: CellSelectionModel for CustomDataView and SlickCustomTooltip (#963)
Browse files Browse the repository at this point in the history
fix: CellSelectionModel for CustomDataView and SlickCustomTooltip
  • Loading branch information
jesenko committed Jan 6, 2024
1 parent f8574ba commit a8b48eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/plugins/slick.cellselectionmodel.ts
@@ -1,6 +1,6 @@
import { SlickEvent as SlickEvent_, SlickEventData as SlickEventData_, SlickRange as SlickRange_, Utils as Utils_ } from '../slick.core';
import { SlickCellRangeSelector as SlickCellRangeSelector_ } from './slick.cellrangeselector';
import type { OnActiveCellChangedEventArgs } from '../models/index';
import type { CustomDataView, OnActiveCellChangedEventArgs } from '../models/index';
import type { SlickDataView } from '../slick.dataview';
import type { SlickGrid } from '../slick.grid';

Expand All @@ -25,7 +25,7 @@ export class SlickCellSelectionModel {
// --
// protected props
protected _cachedPageRowCount = 0;
protected _dataView?: SlickDataView;
protected _dataView?: CustomDataView | SlickDataView;
protected _grid!: SlickGrid;
protected _prevSelectedRow?: number;
protected _prevKeyDown = '';
Expand All @@ -48,7 +48,7 @@ export class SlickCellSelectionModel {
this._options = Utils.extend(true, {}, this._defaults, this._options);
this._grid = grid;
if (grid.hasDataView()) {
this._dataView = grid.getData<SlickDataView>();
this._dataView = grid.getData<CustomDataView | SlickDataView>();
}
this._grid.onActiveCellChanged.subscribe(this.handleActiveCellChange.bind(this));
this._grid.onKeyDown.subscribe(this.handleKeyDown.bind(this));
Expand Down Expand Up @@ -160,7 +160,7 @@ export class SlickCellSelectionModel {
const colLn = this._grid.getColumns().length;
const active = this._grid.getActiveCell();
let dataLn = 0;
if (this._dataView) {
if (this._dataView && 'getPagingInfo' in this._dataView) {
dataLn = this._dataView?.getPagingInfo().pageSize || this._dataView.getLength();
} else {
dataLn = this._grid.getDataLength();
Expand Down
8 changes: 3 additions & 5 deletions src/plugins/slick.customtooltip.ts
@@ -1,6 +1,5 @@
import type { CancellablePromiseWrapper, Column, CustomTooltipOption, DOMEvent, Formatter, FormatterResultWithHtml, FormatterResultWithText, GridOption } from '../models/index';
import type { CancellablePromiseWrapper, Column, CustomDataView, CustomTooltipOption, DOMEvent, Formatter, FormatterResultWithHtml, FormatterResultWithText, GridOption } from '../models/index';
import { SlickEventHandler as SlickEventHandler_, Utils as Utils_ } from '../slick.core';
import type { SlickDataView } from '../slick.dataview';
import type { SlickGrid } from '../slick.grid';

// for (iife) load Slick methods from global Slick object, or use imports for (esm)
Expand Down Expand Up @@ -87,7 +86,7 @@ export class SlickCustomTooltip {
// protected props
protected _cancellablePromise?: CancellablePromiseWrapper;
protected _cellNodeElm?: HTMLDivElement;
protected _dataView?: SlickDataView | null;
protected _dataView?: CustomDataView | null;
protected _grid!: SlickGrid;
protected _gridOptions!: GridOption;
protected _tooltipElm?: HTMLDivElement;
Expand All @@ -113,7 +112,7 @@ export class SlickCustomTooltip {
init(grid: SlickGrid) {
this._grid = grid;
const _data = grid?.getData() || [];
this._dataView = Array.isArray(_data) ? null : _data as SlickDataView;
this._dataView = Array.isArray(_data) ? null : _data as CustomDataView;
this._gridOptions = (grid.getOptions() || {}) as GridOption;
this._options = Utils.extend(true, {}, this._defaults, this._gridOptions.customTooltip, this.tooltipOptions);
this._eventHandler
Expand Down Expand Up @@ -528,4 +527,3 @@ if (IIFE_ONLY && window.Slick) {
}
});
}

0 comments on commit a8b48eb

Please sign in to comment.