Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Dec 8, 2023
2 parents 8749bfe + 918efa4 commit 524331e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/models/gridOption.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ export interface GridOption<C extends BaseColumn = BaseColumn> {
/** Default cell Formatter that will be used by the grid */
defaultFormatter?: Formatter;

/** Escape hatch geared towards testing Slickgrid in jsdom based environments to circumvent the lack of stylesheet.ownerNode and clientWidth calculations */
devMode?: false & { ownerNodeIndex?: number; containerClientWidth?: number; };

/** Do we have paging enabled? */
doPaging?: boolean;

Expand Down
7 changes: 6 additions & 1 deletion src/slick.grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2467,6 +2467,11 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
let i: number;
if (!this.stylesheet) {
const sheets: any = (this._options.shadowRoot || document).styleSheets;

if (typeof this.options.devMode?.ownerNodeIndex === "number" && this.options.devMode.ownerNodeIndex >= 0) {
sheets[this.options.devMode.ownerNodeIndex].ownerNode = this._style;
}

for (i = 0; i < sheets.length; i++) {
if ((sheets[i].ownerNode || sheets[i].owningElement) === this._style) {
this.stylesheet = sheets[i];
Expand Down Expand Up @@ -4285,7 +4290,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
}

getViewportWidth() {
this.viewportW = parseFloat(Utils.innerSize(this._container, 'width') as unknown as string);
this.viewportW = parseFloat(Utils.innerSize(this._container, 'width') as unknown as string) || this.options.devMode?.containerClientWidth || 0;
return this.viewportW;
}

Expand Down

0 comments on commit 524331e

Please sign in to comment.