Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: arguments of getViewportNode() should all be optional #860

Merged
merged 1 commit into from
Oct 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 40 additions & 25 deletions src/slick.grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
}

/** Get the Viewport DOM node element */
getViewportNode(columnIdOrIdx: number | string, rowIndex: number) {
getViewportNode(columnIdOrIdx?: number | string, rowIndex?: number) {
return this._getContainerElement(this.getViewports(), columnIdOrIdx, rowIndex);
}

Expand Down Expand Up @@ -1278,7 +1278,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
/**
* Updates an existing column definition and a corresponding header DOM element with the new title and tooltip.
* @param {Number|String} columnId Column id.
* @param {String} title New column name.
* @param {String} [title] New column name.
* @param {String} [toolTip] New column tooltip.
*/
updateColumnHeader(columnId: number | string, title?: string, toolTip?: string) {
Expand Down Expand Up @@ -1330,8 +1330,8 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
}

/**
* Get a specific Header Column DOM element
* @param {Number|String} [columnIdOrIdx] - column Id or index
* Get a specific Header Column DOM element by its column Id or index
* @param {Number|String} columnIdOrIdx - column Id or index
*/
getHeaderColumn(columnIdOrIdx: number | string) {
const idx = (typeof columnIdOrIdx === 'number' ? columnIdOrIdx : this.getColumnIndex(columnIdOrIdx));
Expand Down Expand Up @@ -1367,8 +1367,8 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
}

/**
* Get Header Row Column DOM element by its column Id
* @param {Number|String} [columnIdOrIdx] - column Id or index
* Get Header Row Column DOM element by its column Id or index
* @param {Number|String} columnIdOrIdx - column Id or index
*/
getHeaderRowColumn(columnIdOrIdx: number | string) {
let idx = (typeof columnIdOrIdx === 'number' ? columnIdOrIdx : this.getColumnIndex(columnIdOrIdx));
Expand All @@ -1388,7 +1388,10 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
return headerRowTarget.children[idx] as HTMLDivElement;
}

/** Get the Footer Row Column DOM element */
/**
* Get the Footer Row Column DOM element by its column Id or index
* @param {Number|String} columnIdOrIdx - column Id or index
*/
getFooterRowColumn(columnIdOrIdx: number | string) {
let idx = (typeof columnIdOrIdx === 'number' ? columnIdOrIdx : this.getColumnIndex(columnIdOrIdx));
let footerRowTarget: HTMLDivElement;
Expand Down Expand Up @@ -3123,7 +3126,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e

/**
* Returns the index of a column with a given id. Since columns can be reordered by the user, this can be used to get the column definition independent of the order:
* @param id A column id.
* @param {String | Number} id A column id.
*/
getColumnIndex(id: number | string): number {
return this.columnsById[id];
Expand Down Expand Up @@ -3174,8 +3177,8 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e

/**
* Accepts a columnId string and an ascending boolean. Applies a sort glyph in either ascending or descending form to the header of the column. Note that this does not actually sort the column. It only adds the sort glyph to the header.
* @param columnId
* @param ascending
* @param {String | Number} columnId
* @param {Boolean} ascending
*/
setSortColumn(columnId: number | string, ascending: boolean) {
this.setSortColumns([{ columnId, sortAsc: ascending }]);
Expand Down Expand Up @@ -3349,7 +3352,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e

/**
* Sets grid columns. Column headers will be recreated and all rendered rows will be removed. To rerender the grid (if necessary), call render().
* @param columnDefinitions An array of column definitions.
* @param {Column[]} columnDefinitions An array of column definitions.
*/
setColumns(columnDefinitions: C[]) {
this.trigger(this.onBeforeSetColumns, { previousColumns: this.columns, newColumns: columnDefinitions, grid: this });
Expand Down Expand Up @@ -3521,7 +3524,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e

/**
* Returns the databinding item at a given position.
* @param index Item row index.
* @param {Number} index Item row index.
*/
getDataItem(i: number): TData {
if ((this.data as CustomDataView).getItem) {
Expand Down Expand Up @@ -3630,7 +3633,10 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
return Math.floor((y + this.offset) / this._options.rowHeight!);
}

/** Scroll to an Y position in the grid */
/**
* Scroll to an Y position in the grid
* @param {Number} y
*/
scrollTo(y: number) {
y = Math.max(y, 0);
y = Math.min(y, (this.th || 0) - (Utils.height(this._viewportScrollContainerY) as number) + ((this.viewportHasHScroll || this.hasFrozenColumns()) ? (this.scrollbarDimensions?.height ?? 0) : 0));
Expand Down Expand Up @@ -3887,7 +3893,10 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
if (this._options.enableAsyncPostRenderCleanup) { this.startPostProcessingCleanup(); }
}

/** Invalidate a specific set of row numbers */
/**
* Invalidate a specific set of row numbers
* @param {Number[]} rows
*/
invalidateRows(rows: number[]) {
if (!rows || !rows.length) {
return;
Expand All @@ -3905,7 +3914,10 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
if (this._options.enableAsyncPostRenderCleanup) { this.startPostProcessingCleanup(); }
}

/** Invalidate a specific row number */
/**
* Invalidate a specific row number
* @param {Number} row
*/
invalidateRow(row?: number) {
if (!row && row !== 0) { return; }
this.invalidateRows([row]);
Expand Down Expand Up @@ -4095,7 +4107,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
return this.viewportW;
}

/** Execute a Resize of the Canvas */
/** Execute a Resize of the Grid Canvas */
resizeCanvas() {
if (!this.initialized) { return; }
this.paneTopH = 0;
Expand Down Expand Up @@ -4202,7 +4214,10 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
this.render();
}

/** Update paging information status from the View */
/**
* Update paging information status from the View
* @param {PagingInfo} pagingInfo
*/
updatePagingStatusFromView(pagingInfo: PagingInfo) {
this.pagingActive = (pagingInfo.pageSize !== 0);
this.pagingIsLastPage = (pagingInfo.pageNum == pagingInfo.totalPages - 1);
Expand Down Expand Up @@ -4960,8 +4975,8 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e

/**
* Adds an "overlay" of CSS classes to cell DOM elements. SlickGrid can have many such overlays associated with different keys and they are frequently used by plugins. For example, SlickGrid uses this method internally to decorate selected cells with selectedCellCssClass (see options).
* @param key A unique key you can use in calls to setCellCssStyles and removeCellCssStyles. If a hash with that key has already been set, an exception will be thrown.
* @param hash A hash of additional cell CSS classes keyed by row number and then by column id. Multiple CSS classes can be specified and separated by space.
* @param {String} key A unique key you can use in calls to setCellCssStyles and removeCellCssStyles. If a hash with that key has already been set, an exception will be thrown.
* @param {CssStyleHash} hash A hash of additional cell CSS classes keyed by row number and then by column id. Multiple CSS classes can be specified and separated by space.
* @example
* `{
* 0: { number_column: SlickEvent; title_column: SlickEvent; },
Expand All @@ -4980,7 +4995,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e

/**
* Removes an "overlay" of CSS classes from cell DOM elements. See setCellCssStyles for more.
* @param key A string key.
* @param {String} key A string key.
*/
removeCellCssStyles(key: string) {
if (!this.cellCssClasses[key]) {
Expand Down Expand Up @@ -5018,9 +5033,9 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e

/**
* Flashes the cell twice by toggling the CSS class 4 times.
* @param {number} row A row index.
* @param {number} cell A column index.
* @param {number} [speed] (optional) - The milliseconds delay between the toggling calls. Defaults to 100 ms.
* @param {Number} row A row index.
* @param {Number} cell A column index.
* @param {Number} [speed] (optional) - The milliseconds delay between the toggling calls. Defaults to 100 ms.
*/
flashCell(row: number, cell: number, speed?: number) {
speed = speed || 250;
Expand Down Expand Up @@ -5449,8 +5464,8 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e

/**
* Returns an object representing information about a cell's position. All coordinates are absolute and take into consideration the visibility and scrolling position of all ancestors.
* @param row A row number.
* @param cell A column number.
* @param {Number} row - A row number.
* @param {Number} cell - A column number.
*/
getCellNodeBox(row: number, cell: number) {
if (!this.cellExists(row, cell)) {
Expand Down