Skip to content

Commit a9e7e53

Browse files
authored
fix: add throwWhenFrozenNotAllViewable grid option to avoid throwing (#882)
- add a flag `throwWhenFrozenNotAllViewable` that will now be set to `false` by default since this was causing issues in our environment, the flag can be set to `true` if any user want to add a try/catch and do other thing instead of simply throwing and leaving the grid in a non-functional state
1 parent 93900ec commit a9e7e53

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/models/gridOption.interface.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,12 @@ export interface GridOption<C extends BaseColumn = BaseColumn> {
282282
/** Defaults to false, when set to True will sync the column cell resize & apply the column width */
283283
syncColumnCellResize?: boolean;
284284

285+
/**
286+
* Defaults to false, should we throw an erro when frozenColumn is wider than the grid viewport width.
287+
* When that happens the unfrozen section on the right is in a phantom area that is not viewable neither clickable unless we enable double-scroll on the grid container.
288+
*/
289+
throwWhenFrozenNotAllViewable?: boolean;
290+
285291
/** What is the top panel height in pixels (only type the number) */
286292
topPanelHeight?: number;
287293

src/slick.grid.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
249249
frozenColumn: -1,
250250
frozenRow: -1,
251251
frozenRightViewportMinWidth: 100,
252+
throwWhenFrozenNotAllViewable: false,
252253
fullWidthRows: false,
253254
multiColumnSort: false,
254255
numberedMultiColumnSort: false,
@@ -1119,7 +1120,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
11191120

11201121
if (this.hasFrozenColumns()) {
11211122
const cWidth = Utils.width(this._container) || 0;
1122-
if (cWidth > 0 && this.canvasWidthL > cWidth) {
1123+
if (cWidth > 0 && this.canvasWidthL > cWidth && this._options.throwWhenFrozenNotAllViewable) {
11231124
throw new Error('[SlickGrid] Frozen columns cannot be wider than the actual grid container width. '
11241125
+ 'Make sure to have less columns freezed or make your grid container wider');
11251126
}

0 commit comments

Comments
 (0)