Skip to content

Commit

Permalink
fix(resizer): allow gridHeight/gridWidth to be passed as string
Browse files Browse the repository at this point in the history
- fixes Aurelia-Slickgrid issue [#534](ghiscoding/aurelia-slickgrid#534)
  • Loading branch information
ghiscoding committed Mar 15, 2021
1 parent bb7dcd3 commit 2fa8ba5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
14 changes: 10 additions & 4 deletions packages/common/src/interfaces/gridOption.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,17 +384,23 @@ export interface GridOption {
/** Grid DOM element container ID (used Slickgrid-Universal auto-resizer) */
gridContainerId?: string;

/** When using a fixed grid height */
gridHeight?: number;
/**
* When using a fixed grid height, can be a number or a string.
* if a number is provided it will add the `px` suffix for pixels, or if a string is passed it will use it as is.
*/
gridHeight?: number | string;

/** Grid DOM element ID */
gridId?: string;

/** Grid Menu options (aka hamburger menu) */
gridMenu?: GridMenu;

/** When using a fixed grid width */
gridWidth?: number;
/**
* When using a fixed grid width, can be a number or a string.
* if a number is provided it will add the `px` suffix for pixels, or if a string is passed it will use it as is.
*/
gridWidth?: number | string;

/** Header row height in pixels (only type the number). Header row is where the filters are. */
headerRowHeight?: number;
Expand Down
14 changes: 10 additions & 4 deletions packages/common/src/interfaces/gridSize.interface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
export interface GridSize {
/** Height of the grid */
height?: number;
/**
* When using a fixed grid height, can be a number or a string.
* if a number is provided it will add the `px` suffix for pixels, or if a string is passed it will use it as is.
*/
height?: number | string;

/** Width of the grid */
width?: number;
/**
* When using a fixed grid width, can be a number or a string.
* if a number is provided it will add the `px` suffix for pixels, or if a string is passed it will use it as is.
*/
width?: number | string;
}
6 changes: 3 additions & 3 deletions packages/vanilla-bundle/src/services/resizer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class ResizerService {
autoResizeOptions.bottomPadding += DATAGRID_PAGINATION_HEIGHT;
}
if (fixedGridDimensions?.width && gridParentContainerElm?.style) {
gridParentContainerElm.style.width = `${fixedGridDimensions.width}px`;
gridParentContainerElm.style.width = typeof fixedGridDimensions.width === 'string' ? fixedGridDimensions.width : `${fixedGridDimensions.width}px`;
}

this._addon = new Slick.Plugins.Resizer({ ...autoResizeOptions, gridContainer: gridParentContainerElm }, fixedGridDimensions);
Expand Down Expand Up @@ -105,7 +105,7 @@ export class ResizerService {

/**
* Return the last resize dimensions used by the service
* @return {object} last dimensions (height: number, width: number)
* @return {object} last dimensions (height, width)
*/
getLastResizeDimensions(): GridSize {
return this._addon?.getLastResizeDimensions();
Expand All @@ -126,7 +126,7 @@ export class ResizerService {
/**
* Resize the datagrid to fit the browser height & width.
* @param {number} delay to wait before resizing, defaults to 0 (in milliseconds)
* @param {object} newSizes can optionally be passed (height: number, width: number)
* @param {object} newSizes can optionally be passed (height, width)
* @param {object} event that triggered the resize, defaults to null
* @return If the browser supports it, we can return a Promise that would resolve with the new dimensions
*/
Expand Down

0 comments on commit 2fa8ba5

Please sign in to comment.