diff --git a/ui-grid/ui-grid-tests.ts b/ui-grid/ui-grid-tests.ts index f4bcdce7e..95c81298a 100644 --- a/ui-grid/ui-grid-tests.ts +++ b/ui-grid/ui-grid-tests.ts @@ -1,20 +1,26 @@ /// /// -var columnDef: uiGrid.IColumnDef; +interface IMyEntity { + name: string; + age: number; +} + +var columnDef: uiGrid.IColumnDefOf; columnDef.aggregationHideLabel = true; columnDef.aggregationHideLabel = false; columnDef.aggregationType = 1; columnDef.aggregationType = function () { return 1; }; columnDef.cellClass = 'test'; -columnDef.cellClass = function (gridRow: uiGrid.IGridRow, gridCol: uiGrid.IGridColumn, index: number) { - return 'pizza'; +columnDef.cellClass = (gridRow, gridCol, index) => { + //types of gridRow, gridCol, and index are flowed in correctly + return `${gridRow.entity.name}-${gridCol.field}-${index + 1}`; }; columnDef.cellFilter = 'date'; columnDef.cellTemplate = '
hello
'; columnDef.cellTooltip = 'blah'; columnDef.cellTooltip = function (gridRow: uiGrid.IGridRow, gridCol: uiGrid.IGridColumn) { - return 'blah'; + return `${gridRow.entity.unknownProperty}-${gridCol.displayName}`; }; columnDef.displayName = 'Jumper'; columnDef.enableColumnMenu = false; @@ -38,24 +44,26 @@ columnDef.filter = { columnDef.filterCellFiltered = false; columnDef.filterHeaderTemplate = '
'; columnDef.filters = [columnDef.filter]; -columnDef.footerCellClass = - (gridRow: uiGrid.IGridRow, rowRenderIndex: number, gridCol: uiGrid.IGridColumn, colRenderIndex: number) => { - return 'blah'; +columnDef.footerCellClass = (gridRow, rowRenderIndex, gridCol, colRenderIndex) => { + //types for gridRow, rowRenderIndex, gridCol, and colRenderIndex flow in properly + return `${gridRow.entity.age}-${rowRenderIndex + 1}-${gridCol.field}-${colRenderIndex - 1}`; }; columnDef.footerCellClass = 'theClass'; columnDef.footerCellFilter = 'currency:$'; columnDef.footerCellTemplate = '
'; columnDef.headerCellClass = - (gridRow: uiGrid.IGridRow, rowRenderIndex: number, gridCol: uiGrid.IGridColumn, colRenderIndex: number) => { - return 'blah'; + (gridRow, rowRenderIndex, gridCol, colRenderIndex) => { + //types for gridRow, rowRenderIndex, gridCol, and colRenderIndex flow in properly + return `${gridRow.entity.age}-${rowRenderIndex + 1}-${gridCol.field}-${colRenderIndex - 1}`; }; columnDef.headerCellClass = 'classy'; columnDef.headerCellFilter = 'currency:$'; columnDef.headerCellTemplate = '
'; columnDef.headerTooltip = false; columnDef.headerTooltip = 'The Tooltip'; -columnDef.headerTooltip = (col: uiGrid.IGridColumn) => { - return 'tooly'; +columnDef.headerTooltip = (col) => { + //type of col flows in properly + return col.displayName; }; columnDef.maxWidth = 200; columnDef.menuItems = [{ @@ -87,10 +95,10 @@ columnDef.width = 100; columnDef.width = '*'; -var gridApi: uiGrid.IGridApi; -var gridInstance: uiGrid.IGridInstance; +var gridApi: uiGrid.IGridApiOf; +var gridInstance: uiGrid.IGridInstanceOf; var menuItem: uiGrid.IMenuItem; -var colProcessor: uiGrid.IColumnProcessor; +var colProcessor: uiGrid.IColumnProcessor; gridApi.core.clearAllFilters(true); gridApi.core.addToGridMenu(gridInstance, [menuItem]); @@ -100,11 +108,25 @@ gridApi.core.queueGridRefresh() gridApi.core.queueRefresh(); gridApi.core.registerColumnsProcessor(colProcessor, 100); -var rowEntityToScrollTo = {anObject: 'inGridOptionsData'}; +var gridOptions: uiGrid.IGridOptionsOf = { + data: [{name: 'Bob', age: 100}], + onRegisterApi: (api) => { + api.selection.on.rowSelectionChanged(null, (row) => { + console.log(row.entity.name); + }) + } +} +interface IAnotherEntity { + anObject: string +} +var anotherGridInstance: uiGrid.IGridInstance; +var rowEntityToScrollTo = { + anObject: 'inGridOptionsData' +}; var columnDefToScrollTo: uiGrid.IColumnDef; -gridInstance.scrollTo(); -gridInstance.scrollTo(rowEntityToScrollTo); -gridInstance.scrollTo(rowEntityToScrollTo, columnDefToScrollTo); +anotherGridInstance.scrollTo(); +anotherGridInstance.scrollTo(rowEntityToScrollTo); +anotherGridInstance.scrollTo(rowEntityToScrollTo, columnDefToScrollTo); -var selectedRowEntities: Array = gridApi.selection.getSelectedRows(); +var selectedRowEntities: Array = gridApi.selection.getSelectedRows(); var selectedGridRows: Array = gridApi.selection.getSelectedGridRows(); diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index ece964280..481326b13 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -1,6 +1,6 @@ // Type definitions for ui-grid // Project: http://www.ui-grid.info/ -// Definitions by: Ben Tesser +// Definitions by: Ben Tesser , Joe Skeen // Definitions: https://github.com/borisyankov/DefinitelyTyped // These are very definitely preliminary. Please feel free to improve. @@ -120,12 +120,13 @@ declare module uiGrid { ALWAYS: number; } } - export interface IGridInstance { + export type IGridInstance = IGridInstanceOf; + export interface IGridInstanceOf { /** * adds a row header column to the grid * @param {IColumnDef} colDef The column definition */ - addRowHeaderColumn(colDef: IColumnDef): void; + addRowHeaderColumn(colDef: IColumnDefOf): void; /** * uses the first row of data to assign colDef.type for any types not defined. */ @@ -134,7 +135,7 @@ declare module uiGrid { * Populates columnDefs from the provided data * @param {IRowBuilder} rowBuilder function to be called */ - buildColumnDefsFromData(rowBuilder: IRowBuilder): void; + buildColumnDefsFromData(rowBuilder: IRowBuilder): void; /** * creates GridColumn objects from the columnDefinition. * Calls each registered columnBuilder to further process the column @@ -193,48 +194,48 @@ declare module uiGrid { * @param {IGridColumn} col Column to access * @returns {string} Cell display value */ - getCellDisplayValue(row: IGridRow, col: IGridColumn): string; + getCellDisplayValue(row: IGridRowOf, col: IGridColumnOf): string; /** * Gets the displayed value of a cell * @param {IGridRow} row Row to access * @param {IGridColumn} col Column to access * @returns {any} Cell value */ - getCellValue(row: IGridRow, col: IGridColumn): any; + getCellValue(row: IGridRowOf, col: IGridColumnOf): any; /** * returns a grid colDef for the column name * @param {string} name Column name * @returns {IColumnDef} The column definition */ - getColDef(name: string): IColumnDef; + getColDef(name: string): IColumnDefOf; /** * returns a grid column by name * @param {string} name Column name * @returns {IGridColumn} The column */ - getColumn(name: string): IGridColumn; + getColumn(name: string): IGridColumnOf; /** * Return the columns that the grid is currently being sorted by * @returns {Array} the columns that the grid is currently being sorted by */ - getColumnSorting(): Array; + getColumnSorting(): Array>; /** * Returns the $parse-able accessor for a column within its $scope * @param {IGridColumn} col Column object * @returns {string} $parse-able accessor for a column within its $scope */ - getGridQualifiedColField(col: IGridColumn): string; + getGridQualifiedColField(col: IGridColumnOf): string; /** * returns all columns except for rowHeader columns * @returns {Array} All data columns */ - getOnlyDataColumns(): Array; + getOnlyDataColumns(): Array>; /** * returns the GridRow that contains the rowEntity - * @param {any} rowEntity the gridOptionms.data array element instance + * @param {TEntity} rowEntity the gridOptionms.data array element instance * @param {Array} rows The rows to look in. if not provided then it looks in grid.rows */ - getRow(rowEntity: any, rows?: Array): IGridRow; + getRow(rowEntity: TEntity, rows?: Array>): IGridRowOf; /** * Triggered when the browser window resizes; automatically resizes the grid * @param {ng.IAngularEvent} $event Resize event @@ -270,7 +271,7 @@ declare module uiGrid { * @param {IGridColumn} column The column * @returns {boolean} true if the column is a row header */ - isRowHeaderColumn(column: IGridColumn): boolean; + isRowHeaderColumn(column: IGridColumnOf): boolean; /** * creates or removes GridRow objects from the newRawData array. Calls each registered * rowBuilder to further process the row @@ -286,10 +287,10 @@ declare module uiGrid { * * Rows are identified using the hashKey if configured. If not configured, then rows * are identified using the gridOptions.rowEquality function - * @param {Array} newRawData The new grid data + * @param {Array} newRawData The new grid data * @return {ng.IPromise} Promise which resolves when the rows have been created or removed */ - modifyRows(newRawData: Array): ng.IPromise; + modifyRows(newRawData: Array): ng.IPromise; /** * Notify the grid that a data or config change has occurred, * where that change isn't something the grid was otherwise noticing. This @@ -309,7 +310,7 @@ declare module uiGrid { * @param {IGridRow} gridRow reference to gridRow * @returns {IGridRow} the gridRow with all additional behavior added */ - processRowBuilders(gridRow: IGridRow): IGridRow; + processRowBuilders(gridRow: IGridRowOf): IGridRowOf; /** * calls the row processors, specifically * intended to reset the sorting when an edit is called, @@ -360,7 +361,7 @@ declare module uiGrid { * additional properties to the column. * @param {IColumnBuilder} columnBuilder function to be called */ - registerColumnBuilder(columnBuilder: IColumnBuilder): void; + registerColumnBuilder(columnBuilder: IColumnBuilder): void; /** * Register a "columns processor" function. When the columns are updated, * the grid calls each registered "columns processor", which has a chance @@ -373,7 +374,7 @@ declare module uiGrid { * for other people to inject columns processors at intermediate priorities. * Lower priority columnsProcessors run earlier.priority */ - registerColumnsProcessor(columnProcessor: IColumnProcessor, priority: number): void; + registerColumnsProcessor(columnProcessor: IColumnProcessor, priority: number): void; /** * When a data change occurs, the data change callbacks of the specified type * will be called. The rules are: @@ -398,13 +399,13 @@ declare module uiGrid { * ALL * @returns {Function} deregister function - a function that can be called to deregister this callback */ - registerDataChangeCallback(callback: (grid: IGridInstance) => void, types: Array): Function; + registerDataChangeCallback(callback: (grid: IGridInstanceOf) => void, types: Array): Function; /** * When the build creates rows from gridOptions.data, the rowBuilders will be called to add * additional properties to the row. * @param {IRowBuilder} rowBuilder Function to be called */ - registerRowBuilder(rowBuilder: IRowBuilder): void; + registerRowBuilder(rowBuilder: IRowBuilder): void; /** * Register a "rows processor" function. When the rows are updated, * the grid calls each registered "rows processor", which has a chance @@ -420,7 +421,7 @@ declare module uiGrid { * is running at 50, filter is running at 100, sort is at 200, grouping at 400, selectable rows at * 500, pagination at 900 (pagination will generally want to be last) */ - registerRowsProcessor(rowProcessor: IRowProcessor, priority: number): void; + registerRowsProcessor(rowProcessor: IRowProcessor, priority: number): void; /** * registered a styleComputation function * @@ -432,20 +433,20 @@ declare module uiGrid { * Remove a registered rows processor * @param {IRowProcessor} rows processor function */ - removeRowsProcessor(rows: IRowProcessor): void; + removeRowsProcessor(rows: IRowProcessor): void; /** * Return the columns that the grid is currently being sorted by * @param {IGridColumn} [excludedColumn] Optional GridColumn to exclude from having its sorting reset */ - resetColumnSorting(excludedColumn: IGridColumn): void; + resetColumnSorting(excludedColumn: IGridColumnOf): void; /** * Scroll the grid such that the specified * row and column is in view - * @param {any} rowEntity gridOptions.data[] array instance to make visible + * @param {TEntity} rowEntity gridOptions.data[] array element to make visible * @param {IColumnDef} colDef to make visible * @returns {ng.IPromise} a promise that is resolved after any scrolling is finished */ - scrollTo(rowEntity?: any, colDef?: IColumnDef): ng.IPromise; + scrollTo(rowEntity?: TEntity, colDef?: IColumnDefOf): ng.IPromise; /** * Scrolls the grid to make a certain row and column combo visible, * in the case that it is not completely visible on the screen already. @@ -453,7 +454,7 @@ declare module uiGrid { * @param {IGridColumn} gridCol column to make visible * @returns {ng.IPromise} a promise that is resolved when scrolling is complete */ - scrollToIfNecessary(gridRow: IGridRow, gridCol: IGridColumn): ng.IPromise; + scrollToIfNecessary(gridRow: IGridRowOf, gridCol: IGridColumnOf): ng.IPromise; /** * Set the sorting on a given column, optionally resetting any existing sorting on the Grid. * Emits the sortChanged event whenever the sort criteria are changed. @@ -465,7 +466,8 @@ declare module uiGrid { * reset any existing sorting and sort by this column only * @returns {ng.IPromise} A resolved promise that supplies the column. */ - sortColumn(column: IGridColumn, direction?: string, add?: boolean): ng.IPromise; + sortColumn(column: IGridColumnOf, direction?: string, add?: boolean) + : ng.IPromise>; /** * flags all render containers to update their canvas height */ @@ -513,23 +515,26 @@ declare module uiGrid { export interface IStyleComputation { ($scope: ng.IScope): string; } - export interface IColumnBuilder { - (colDef: IColumnDef, col: IGridColumn, gridOptions: IGridOptions): void; + export interface IColumnBuilder { + (colDef: IColumnDefOf, col: IGridColumnOf, gridOptions: IGridOptionsOf): void; } - export interface IRowBuilder { - (row: IGridRow, gridOptions: IGridOptions): void; + export interface IRowBuilder { + (row: IGridRowOf, gridOptions: IGridOptionsOf): void; } - export interface IRowProcessor { - (renderedRowsToProcess: Array, columns: Array): Array; + export interface IRowProcessor { + (renderedRowsToProcess: Array>, columns: Array>) + : Array>; } - export interface IColumnProcessor { - (renderedColumnsToProcess: Array, rows: Array): Array; + export interface IColumnProcessor { + (renderedColumnsToProcess: Array>, rows: Array>) + : Array>; } - export interface IGridOptions extends cellNav.IGridOptions, edit.IGridOptions, expandable.IGridOptions, - exporter.IGridOptions, grouping.IGridOptions, importer.IGridOptions, infiniteScroll.IGridOptions, - moveColumns.IGridOptions, pagination.IGridOptions, pinning.IGridOptions, resizeColumns.IGridOptions, - rowEdit.IGridOptions, saveState.IGridOptions, selection.IGridOptions, treeBase.IGridOptions, - treeView.IGridOptions { + export type IGridOptions = IGridOptionsOf; + export interface IGridOptionsOf extends cellNav.IGridOptions, edit.IGridOptions, expandable.IGridOptions, + exporter.IGridOptions, grouping.IGridOptions, importer.IGridOptions, + infiniteScroll.IGridOptions, moveColumns.IGridOptions, pagination.IGridOptions, pinning.IGridOptions, + resizeColumns.IGridOptions, rowEdit.IGridOptions, saveState.IGridOptions, selection.IGridOptions, + treeBase.IGridOptions, treeView.IGridOptions { /** * Default time in milliseconds to throttle aggregation calcuations, defaults to 500ms */ @@ -542,7 +547,7 @@ declare module uiGrid { /** * Array of columnDef objects. Only required property is name. */ - columnDefs?: Array; + columnDefs?: Array>; /** * The height of the footer rows (column footer and grid footer) in pixels */ @@ -586,7 +591,7 @@ declare module uiGrid { * Where you do this, you need to take care in updating the data - you can't just update `$scope.myData` to some * other array, you need to update $scope.gridOptions.data to point to that new array as well. */ - data?: Array | string; + data?: Array | string; /** * True by default. When enabled, this setting displays a column * menu within each column. @@ -737,7 +742,7 @@ declare module uiGrid { * if needed * @param {IGridApi} gridApi */ - onRegisterApi?: (gridApi: IGridApi) => void; + onRegisterApi?: (gridApi: IGridApiOf) => void; /** * The height of the row in pixels, defaults to 30 * @default 30 @@ -805,14 +810,14 @@ declare module uiGrid { * @param {IGridRow} row The row for which you want the unique id * @returns {string} row uid */ - getRowIdentity?(row: IGridRow): any; + getRowIdentity?(row: IGridRowOf): any; /** * By default, rows are compared using object equality. This option can be overridden * to compare on any data item property or function - * @param {any} entityA First Data Item to compare - * @param {any} entityB Second Data Item to compare + * @param {TEntity} entityA First Data Item to compare + * @param {TEntity} entityB Second Data Item to compare */ - rowEquality?(entityA: any, entityB: any): boolean; + rowEquality?(entityA: TEntity, entityB: TEntity): boolean; /** * This function is used to get and, if necessary, set the value uniquely identifying this row * (i.e. if an identity is not present it will set one). @@ -822,13 +827,13 @@ declare module uiGrid { */ rowIdentity?(): any; } - export interface IGridCoreApi { + export interface IGridCoreApi { // Methods /** * adds a row header column to the grid * @param {IColumnDef} column Column Definition */ - addRowHeaderColumn(column: IColumnDef): void; + addRowHeaderColumn(column: IColumnDefOf): void; /** * add items to the grid menu. Used by features * to add their menu items if they are enabled, can also be used by @@ -842,7 +847,7 @@ declare module uiGrid { * which is provided when you want to remove an item. The id should be unique. */ - addToGridMenu(grid: IGridInstance, items: Array): void; + addToGridMenu(grid: IGridInstanceOf, items: Array): void; /** * Clears all filters and optionally refreshes the visible rows. * @param {boolean} [refreshRows=true] Defaults to true. @@ -851,22 +856,22 @@ declare module uiGrid { * @returns {ng.IPromise} If `refreshRows` is true, returns a promise of the rows refreshing. */ clearAllFilters(refreshRows?: boolean, clearConditions?: boolean, - clearFlags?: boolean): ng.IPromise>; + clearFlags?: boolean): ng.IPromise>>; /** * Clears any override on visibility for the row so that it returns to * using normal filtering and other visibility calculations. * If the row is currently invisible then sets it to visible and calls * both grid refresh and emits the rowsVisibleChanged event * TODO: if a filter is active then we can't just set it to visible? - * @param {any} rowEntity gridOptions.data[] array instance + * @param {TEntity} rowEntity gridOptions.data[] array instance */ - clearRowInvisible(rowEntity: any): void; + clearRowInvisible(rowEntity: TEntity): void; /** * Returns all visible rows * @param {IGridInstance} grid the grid you want to get visible rows from * @returns {Array} an array of gridRow */ - getVisibleRows(grid: IGridInstance): Array; + getVisibleRows(grid: IGridInstanceOf): Array>; /** * Trigger a grid resize, normally this would be picked * up by a watch on window size, but in some circumstances it is necessary @@ -906,7 +911,7 @@ declare module uiGrid { * At present allRowsVisible is running at 50, filter is running at 100, sort is at 200, grouping at 400, * selectable rows at 500, pagination at 900 (pagination will generally want to be last) */ - registerColumnsProcessor(processorFunction: IColumnProcessor, priority: number): void; + registerColumnsProcessor(processorFunction: IColumnProcessor, priority: number): void; /** * Register a "rows processor" function. When the rows are updated, * the grid calls each registered "rows processor", which has a chance @@ -923,15 +928,15 @@ declare module uiGrid { * At present all rows visible is running at 50, filter is running at 100, sort is at 200, grouping at 400, * selectable rows at 500, pagination at 900 (pagination will generally want to be last) */ - registerRowsProcessor(rowProcessor: IRowProcessor, priority: number): void; + registerRowsProcessor(rowProcessor: IRowProcessor, priority: number): void; /** * Scroll the grid such that the specified * row and column is in view - * @param {any} entity gridOptions.data[] array instance to make visible + * @param {TEntity} entity gridOptions.data[] array instance to make visible * @param {IColumnDef} colDef to make visible * @returns {ng.IPromise} a promise that is resolved after any scrolling is finished */ - scrollTo(entity: any, colDef: IColumnDef): void; /*A row entity can be anything?*/ + scrollTo(entity: TEntity, colDef: IColumnDefOf): void; /*A row entity can be anything?*/ /** * Scrolls the grid to make a certain row and column combo visible, * in the case that it is not completely visible on the screen already. @@ -939,7 +944,7 @@ declare module uiGrid { * @param {IGridColumn} gridCol column to make visible * @returns {ng.IPromise} a promise that is resolved when scrolling is complete */ - scrollToIfNecessary(gridRow: IGridRow, gridCol: IGridColumn): void; + scrollToIfNecessary(gridRow: IGridRowOf, gridCol: IGridColumnOf): void; /** * A null handling method that can be used when building custom sort * functions @@ -973,7 +978,7 @@ declare module uiGrid { * @param {columnVisibilityChangedHandler} callBack Will be called when the event is emited. * The function passes back the GridCol that has changed */ - columnVisibilityChanged: (scope: ng.IScope, callBack: columnVisibilityChangedHandler) => void; + columnVisibilityChanged: (scope: ng.IScope, callBack: columnVisibilityChangedHandler) => void; /** * is raised after the filter is changed. * The nature of the watch expression doesn't allow notification of what changed, @@ -981,13 +986,13 @@ declare module uiGrid { * @param {ng.IScope} scope Grid scope * @param {filterChangedHandler} handler Callback */ - filterChanged: (scope: ng.IScope, handler: filterChangedHandler) => void; + filterChanged: (scope: ng.IScope, handler: filterChangedHandler) => void; /** * is raised after the cache of visible rows is changed * @param {ng.IScope} scope Grid scope * @param {rowsRenderedHandler} handler callback */ - rowsRendered: (scope: ng.IScope, handler: rowsRenderedHandler) => void; + rowsRendered: (scope: ng.IScope, handler: rowsRenderedHandler) => void; /** * is raised after the rows that are visible change. * The filtering is zero-based, so it isn't possible to say which rows changed @@ -997,7 +1002,7 @@ declare module uiGrid { * @param {ng.IScope} scope Grid scope * @param {rowsVisibleChangedHandler} handler callback */ - rowsVisibleChanged: (scope: ng.IScope, handler: rowsVisibleChangedHandler) => void; + rowsVisibleChanged: (scope: ng.IScope, handler: rowsVisibleChangedHandler) => void; /** * is raised when scroll begins. Is throttled, so won't be raised too frequently * @param {ng.IScope} scope Grid scope @@ -1012,12 +1017,12 @@ declare module uiGrid { scrollEnd: (scope: ng.IScope, handler: scrollEndHandler) => void; } } - export interface columnVisibilityChangedHandler { + export interface columnVisibilityChangedHandler { /** * Column visibility changed event handler * @param {IGridColumn} column Ui Grid column */ - (column: IGridColumn): void; + (column: IGridColumnOf): void; } export interface canvasHeightChangedHandler { /** @@ -1028,28 +1033,28 @@ declare module uiGrid { (oldHeight: number, newHeight: number): void; } - export interface filterChangedHandler{ + export interface filterChangedHandler { /** * Filter changed event callback * @param {IGridApi} gridApi grid api */ - (gridApi: IGridApi): void; + (gridApi: IGridApiOf): void; } - export interface rowsRenderedHandler { + export interface rowsRenderedHandler { /** * Rows rendered event callback * @param {IGridApi} gridApi Grid api object */ - (gridApi: IGridApi): void; + (gridApi: IGridApiOf): void; } - export interface rowsVisibleChangedHandler { + export interface rowsVisibleChangedHandler { /** * Rows visible changed event callback * @param {IGridApi} gridApi grid api object */ - (gridApi: IGridApi): void; + (gridApi: IGridApiOf): void; } export interface scrollBeginHandler { @@ -1106,30 +1111,30 @@ declare module uiGrid { allowCellFocus?: boolean; } - export interface ICellNavApi { + export interface ICellNavApi { // Methods /** * Gets the currently selected rows and columns. array is empty if no selection has occurred * @returns {Array} an array containing the current selection */ - getCurrentSelection(): Array; + getCurrentSelection(): Array>; /** * Gets the current focused cell. value is null if no selection has occurred * @returns {IRowCol} the current (or last if Grid does not have focus) focused row and column */ - getFocusedCell(): IRowCol; + getFocusedCell(): IRowCol; /** * Gets the index of the passed rowCol. Returns -1 if the RowCol isn't selected * @param rowCol * @returns the index in the order in which the RowCol was selected */ - rowColSelectIndex(rowCol: IRowCol): number; + rowColSelectIndex(rowCol: IRowCol): number; /** * Brings the specified row and column into view, and sets focus to that cell - * @param {any} rowEntity gridOptions.data[] array instance to make visible and set focus + * @param {TEntity} rowEntity gridOptions.data[] array instance to make visible and set focus * @param {IColumnDef} colDef Column definition to make visible and set focus */ - scrollToFocus(rowEntity: any, colDef: IColumnDef): ng.IPromise; + scrollToFocus(rowEntity: TEntity, colDef: IColumnDef): ng.IPromise; // Events on: { @@ -1138,7 +1143,7 @@ declare module uiGrid { * @param {ng.IScope} scope The grid scope * @param {navigateHandler} handler Callback */ - navigate: (scope: ng.IScope, handler: navigateHandler) => void; + navigate: (scope: ng.IScope, handler: navigateHandler) => void; /** * viewportKeyDown is raised when the viewPort receives a keyDown event. * Cells never get focus in uiGrid due to the difficulties of setting focus on a cell that is @@ -1146,7 +1151,7 @@ declare module uiGrid { * @param {ng.IScope} scope The grid scope * @param {viewportKeyDownHandler} handler Callback */ - viewportKeyDown: (scope: ng.IScope, handler: viewportKeyDownHandler) => void; + viewportKeyDown: (scope: ng.IScope, handler: viewportKeyDownHandler) => void; /** * viewportKeyPress is raised when the viewPort receives a keyPress event. * Cells never get focus in uiGrid due to the difficulties of setting focus on a cell that is @@ -1154,47 +1159,47 @@ declare module uiGrid { * @param {ng.IScope} scope The grid scope * @param {viewportKeyPressHandler} handler Callback */ - viewportKeyPress: (scope: ng.IScope, handler: viewportKeyPressHandler) => void; + viewportKeyPress: (scope: ng.IScope, handler: viewportKeyPressHandler) => void; } } - export interface navigateHandler { + export interface navigateHandler { /** * Callback for navigate event * @param {IRowCol} newRowCol New position * @param {IRowCol} oldRowCol Old position */ - (newRowCol: IRowCol, oldRowCol: IRowCol): void; + (newRowCol: IRowCol, oldRowCol: IRowCol): void; } - export interface viewportKeyDownHandler { + export interface viewportKeyDownHandler { /** * Callback for viewport key down event * @param {JQueryKeyEventObject} event Keydown event * @param {IRowCol} rowCol Current row Col position */ - (event: JQueryKeyEventObject, rowCol: IRowCol): void; + (event: JQueryKeyEventObject, rowCol: IRowCol): void; } - export interface viewportKeyPressHandler { + export interface viewportKeyPressHandler { /** * Callback for viewport key press event * @param {JQueryKeyEventObject} event Keypress event * @param {IRowCol} rowCol Current row Col position */ - (event: JQueryKeyEventObject, rowCol: IRowCol): void; + (event: JQueryKeyEventObject, rowCol: IRowCol): void; } - export interface IRowColConstructor { - new (row: uiGrid.IGridRow, col: IGridColumn): IRowCol; + export interface IRowColConstructor { + new (row: uiGrid.IGridRowOf, col: IGridColumnOf): IRowCol; } /** * A row and column pair that represents the intersection of these two entities */ - export interface IRowCol { - row: uiGrid.IGridRow; - col: IGridColumn; + export interface IRowCol { + row: uiGrid.IGridRowOf; + col: IGridColumnOf; /** * Gets the intersection of where the row and column meet * @returns The value from the grid data that this RowCol points to. If the column has a cellFilter this @@ -1234,7 +1239,7 @@ declare module uiGrid { /** * Edit related Column Definition */ - export interface IColumnDef { + export interface IColumnDef { /** * If specified, either a value or function evaluated before editing cell. * If falsy, then editing of cell is not allowed. @@ -1286,7 +1291,9 @@ declare module uiGrid { reader.readAsText( files[0] ); } */ - editFileChooserCallback?: (gridRow: uiGrid.IGridRow, gridCol: IGridColumn, files: FileList) => void; + editFileChooserCallback?: (gridRow: uiGrid.IGridRowOf, + gridCol: IGridColumnOf, + files: FileList) => void; /** * A bindable string value that is used when binding to edit controls instead of colDef.field * For example if you have a complex property on an object like: @@ -1360,57 +1367,57 @@ declare module uiGrid { /** * Public Api for edit feature */ - export interface IGridEditApi { + export interface IGridEditApi { on: { /** * raised when cell editing is complete * @param scope The grid scope * @param {afterCellEditHandler} handler Callback */ - afterCellEdit: (scope: ng.IScope, handler: afterCellEditHandler) => void; + afterCellEdit: (scope: ng.IScope, handler: afterCellEditHandler) => void; /** * raised when cell editing starts on a cell * @param scope The grid scope * @param {beginCellEditHandler} handler Callback */ - beginCellEdit: (scope: ng.IScope, handler: beginCellEditHandler) => void; + beginCellEdit: (scope: ng.IScope, handler: beginCellEditHandler) => void; /** * raised when cell editing is cancelled on a cell * @param scope The grid scope * @param {cancelCellEditHandler} handler Callback */ - cancelCellEdit: (scope: ng.IScope, handler: cancelCellEditHandler) => void; + cancelCellEdit: (scope: ng.IScope, handler: cancelCellEditHandler) => void; } } - export interface afterCellEditHandler{ + export interface afterCellEditHandler { /** * raised when cell editing is complete - * @param {any} rowEntity the options.data element that was edited + * @param {TEntity} rowEntity the options.data element that was edited * @param {IColumnDef} colDef The column that was edited * @param {any} newValue New Value * @param {any} oldValue Old Value */ - (rowEntity: any, colDef: IColumnDef, newValue: any, oldValue: any): void; + (rowEntity: TEntity, colDef: IColumnDef, newValue: any, oldValue: any): void; } /** * raised when cell editing starts on a cell - * @param {any} rowEntity the options.data element that was edited + * @param {TEntity} rowEntity the options.data element that was edited * @param {IColumnDef} colDef The column that was edited * @param {JQueryEventObject} triggerEvent the event that triggered the edit. Useful to prevent losing * keystrokes on some complex editors */ - export interface beginCellEditHandler{ - (rowEntity: any, colDef: IColumnDef, triggerEvent: JQueryEventObject): void; + export interface beginCellEditHandler { + (rowEntity: TEntity, colDef: IColumnDef, triggerEvent: JQueryEventObject): void; } /** * raised when cell editing is cancelled on a cell - * @param {any} rowEntity the options.data element that was edited + * @param {TEntity} rowEntity the options.data element that was edited * @param {IColumnDef} colDef The column that was edited */ - export interface cancelCellEditHandler{ - (rowEntity: any, colDef: IColumnDef): void; + export interface cancelCellEditHandler { + (rowEntity: TEntity, colDef: IColumnDef): void; } /** @@ -1462,7 +1469,7 @@ declare module uiGrid { /** * Public Api for expandable feature */ - export interface IGridExpandableApi { + export interface IGridExpandableApi { // Methods /** * Collapse all subgrids. @@ -1478,9 +1485,9 @@ declare module uiGrid { toggleAllRows(): void; /** * Toggle a specific row - * @param {any} rowEntity The data entity for the row you want to expand + * @param {TEntity} rowEntity The data entity for the row you want to expand */ - toggleRowExpansion(rowEntity: any): void; + toggleRowExpansion(rowEntity: TEntity): void; // Events on: { @@ -1489,16 +1496,16 @@ declare module uiGrid { * @param {ng.IScope} scope * @param {rowExpandedStateChangedHandler} handler */ - rowExpandedStateChanged: (scope: ng.IScope, handler: rowExpandedStateChangedHandler) => void; + rowExpandedStateChanged: (scope: ng.IScope, handler: rowExpandedStateChangedHandler) => void; } } - export interface rowExpandedStateChangedHandler { + export interface rowExpandedStateChangedHandler { /** * Raised when cell editing is complete * @param {IGridRow} row The row that was expanded */ - (row: IGridRow): void; + (row: IGridRowOf): void; } } @@ -1521,22 +1528,22 @@ declare module uiGrid { /** * GridOptions for exporter feature, these are available to be set using the ui-grid gridOptions */ - export interface IGridOptions { + export interface IGridOptions { /** * This promise is needed when exporting all rows, and the data need to be provided by server side. * Default is null * @default null - * @returns {ng.IPromise>} A promise to load all data from server + * @returns {ng.IPromise>} A promise to load all data from server */ - exporterAllDataFn?: () => ng.IPromise>; + exporterAllDataFn?: () => ng.IPromise>; /** * @deprecated * DEPRECATED - exporterAllDataFn used to be called this, but it wasn't a promise, * it was a function that returned a promise. Deprecated, but supported for backward compatibility, * use exporterAllDataFn instead. - * @returns {ng.IPromise>} A promise to load all data from server + * @returns {ng.IPromise>} A promise to load all data from server */ - exporterAllDataPromise?: () => ng.IPromise>; + exporterAllDataPromise?: () => ng.IPromise>; /** * The character to use as column separator link * Defaults to ',' @@ -1562,7 +1569,10 @@ declare module uiGrid { * @param {any} value The cell value * @returns {any} Formatted value */ - exporterFieldCallback?: (grid: IGridInstance, row: uiGrid.IGridRow, col: IGridColumn, value: any) => any; + exporterFieldCallback?: (grid: IGridInstanceOf, + row: uiGrid.IGridRowOf, + col: IGridColumnOf, + value: any) => any; /** * A function to apply to the header displayNames before exporting. Useful for internationalisation, * for example if you were using angular-translate you'd set this to $translate.instant. @@ -1831,7 +1841,7 @@ declare module uiGrid { /** * Public Api for grouping feature */ - export interface IGridGroupingApi { + export interface IGridGroupingApi { // Methods /** * Sets the aggregation type on a column. @@ -1888,13 +1898,13 @@ declare module uiGrid { * @param {ng.IScope} scope Grid Scope * @param {aggregationChangedHandler} handler Callback method */ - aggregationChanged: (scope: ng.IScope, handler: aggregationChangedHandler) => void; + aggregationChanged: (scope: ng.IScope, handler: aggregationChangedHandler) => void; /** * raised whenever the grouped columns change * @param {ng.IScope} scope Grid Scope * @param {groupingChangedHandler} handler Callback method */ - groupingChanged: (scope: ng.IScope, handler: groupingChangedHandler) => void; + groupingChanged: (scope: ng.IScope, handler: groupingChangedHandler) => void; }; } /** @@ -1933,22 +1943,22 @@ declare module uiGrid { export interface IGridExpandedHash { [key: string]: IGridExpandedHash | string; } - export interface aggregationChangedHandler { + export interface aggregationChangedHandler { /** * raised whenever aggregation is changed, added or removed from a column * @param {IGridColumn} col the column which on which aggregation changed. * The aggregation type is available as col.treeAggregation.type */ - (col: IGridColumn): void; + (col: IGridColumnOf): void; } - export interface groupingChangedHandler { + export interface groupingChangedHandler { /** * raised whenever the grouped columns changes * @param {IGridColumn} col the column which on which grouping changed. * The new grouping is available as col.grouping */ - (col: IGridColumn): void; + (col: IGridColumnOf): void; } /** @@ -1965,15 +1975,15 @@ declare module uiGrid { /** * GridOptions for importer feature, these are available to be set using the ui-grid gridOptions */ - export interface IGridOptions { + export interface IGridOptions { /** * A mandatory callback function that adds data to the source data array. * The grid generally doesn't add rows to the source data array, * it is tidier to handle this through a user callback. * @param {IGridInstance} grid The grid we're importing into, may be useful in some way - * @param {Array} newObjects An array of new objects that you should add to your data + * @param {Array} newObjects An array of new objects that you should add to your data */ - importerDataAddCallback?: (grid: IGridInstance, newObjects: Array) => void; + importerDataAddCallback?: (grid: IGridInstanceOf, newObjects: Array) => void; /** * A callback function that provides custom error handling, * rather than the standard grid behaviour of an alert box and a console message. @@ -1990,7 +2000,7 @@ declare module uiGrid { * @param {any} context the context data that importer would have appended to that console message, * often the file content itself or the element that is in error */ - importerErrorCallback?: (grid: IGridInstance, errorKey: string, consoleMessage: string, + importerErrorCallback?: (grid: IGridInstanceOf, errorKey: string, consoleMessage: string, context: any) => void; /** * A callback function that will filter (usually translate) a single header. @@ -2006,11 +2016,12 @@ declare module uiGrid { * This callback can be used to change the decoded value back into a code. * Defaults to angular.identity. * @param {IGridInstance} grid The grid - * @param {any} newObject The new object as importer has created it. Modify it and return modified version - * @returns {any} The modified object + * @param {TEntity} newObject The new object as importer has created it. Modify it and return modified + * version + * @returns {TEntity} The modified object * @default angular.identity */ - importerObjectCallback?: (grid: IGridInstance, newObject: any) => any; + importerObjectCallback?: (grid: IGridInstanceOf, newObject: TEntity) => TEntity; /** * A callback function that will process headers using custom * logic. Set this callback function if the headers that your user will provide in their @@ -2029,7 +2040,7 @@ declare module uiGrid { * which you need to match to column.names * @returns {Array} array of matching column names, in the same order as the headerArray */ - importerProcessHeaders?: (grid: IGridInstance, headerArray: Array) => Array; + importerProcessHeaders?: (grid: IGridInstanceOf, headerArray: Array) => Array; /** * Whether or not importer is enabled. Automatically set * to false if the user's browser does not support the required fileApi. @@ -2092,7 +2103,7 @@ declare module uiGrid { /** * Public API for infinite scroll feature */ - export interface IGridInfiniteScrollApi { + export interface IGridInfiniteScrollApi { // Methods /** * Call this function when you have loaded the additional data requested. @@ -2132,7 +2143,7 @@ declare module uiGrid { * @param {boolean} scrollDown flag that there are pages downwards, so fire infinite scroll events downward * @returns {ng.IPromise} A promise that is resolved when scrolling finishes */ - dataRemovedBottom(grid: IGridInstance, scrollUp: boolean, scrollDown: boolean): ng.IPromise; + dataRemovedBottom(grid: IGridInstanceOf, scrollUp: boolean, scrollDown: boolean): ng.IPromise; /** * Adjusts the scroll position after you've removed data at the bottom * @param {boolean} scrollUp flag that there are pages upwards, fire infinite scroll events upward @@ -2151,7 +2162,7 @@ declare module uiGrid { * @param {boolean} scrollDown flag that there are pages downwards, so fire infinite scroll events downward * @returns {ng.IPromise} A promise that is resolved when scrolling finishes */ - dataRemovedTop(grid: IGridInstance, scrollUp: boolean, scrollDown: boolean): ng.IPromise; + dataRemovedTop(grid: IGridInstanceOf, scrollUp: boolean, scrollDown: boolean): ng.IPromise; /** * Call this function when you have taken some action that makes the current scroll position invalid. * For example, if you're using external sorting and you've resorted then you might reset the scroll, @@ -2360,14 +2371,14 @@ declare module uiGrid { enablePinning?: boolean; } - export interface IGridPinningApi { + export interface IGridPinningApi { // Methods /** * Pin column left, right, or none * @param {IGridColumn} col The column being pinned * @param {string} container One of the recognized container types from uiGridPinningConstants */ - pinColumn(col: IGridColumn, container: string): void; + pinColumn(col: IGridColumnOf, container: string): void; // Events /** @@ -2460,7 +2471,7 @@ declare module uiGrid { rowEditWaitInterval?: number; } - export interface IGridRowEditApi { + export interface IGridRowEditApi { // Methods /** * Triggers a save event for all currently dirty rows. @@ -2469,34 +2480,34 @@ declare module uiGrid { * @returns {ng.IPromise>} a promise that represents the aggregate of all of the individual save * promises. i.e. it will be resolved when all the individual save promises have been resolved. */ - flushDirtyRows(grid?: IGridInstance): ng.IPromise>; + flushDirtyRows(grid?: IGridInstanceOf): ng.IPromise>; /** * Returns all currently dirty rows * @param {IGridInstance} grid The target grid * @returns {Array} An array of gridRows that are currently dirty */ - getDirtyRows(grid?: IGridInstance): Array; + getDirtyRows(grid?: IGridInstanceOf): Array>; /** * Returns all currently errored rows * @param {IGridInstance} grid The target grid * @returns {Array} An array of gridRows that are currently in error */ - getErrorRows(grid?: IGridInstance): Array; + getErrorRows(grid?: IGridInstanceOf): Array>; /** * Sets each of the rows passed in dataRows to be clean, * removing them from the dirty cache and the error cache, * and clearing the error flag and the dirty flag - * @param {Array} dataRows the data entities for which the gridRows should be set clean + * @param {Array} dataRows the data entities for which the gridRows should be set clean */ - setRowsClean(dataRows: Array): void; + setRowsClean(dataRows: Array): void; /** * Sets each of the rows passed in dataRows to be dirty, * Note that if you have only just inserted the rows into your data, * you will need to wait for a $digest cycle before the gridRows are present. As a result, this is often * wrapped with $interval or $timeout. - * @param {Array} dataRows the data entities for which the gridRows should be set dirty + * @param {Array} dataRows the data entities for which the gridRows should be set dirty */ - setRowsDirty(dataRows: Array): void; + setRowsDirty(dataRows: Array): void; /** * Sets the promise associated with the row save, mandatory that the saveRow event handler calls this method * somewhere before returning @@ -2519,16 +2530,16 @@ declare module uiGrid { * @param {ng.IScope} scope The grid scope * @param {saveRowHandler} handler Callback */ - saveRow: (scope: ng.IScope, handler: saveRowHandler) => void; + saveRow: (scope: ng.IScope, handler: saveRowHandler) => void; } } - export interface saveRowHandler { + export interface saveRowHandler { /** * Callback method for save row - * @param {any} rowEntity The options.data element that was edited + * @param {TEntity} rowEntity The options.data element that was edited */ - (rowEntity: Array): void; + (rowEntity: TEntity): void; } } @@ -2808,7 +2819,7 @@ declare module uiGrid { /** * Public Api for selection feature */ - export interface IGridSelectionApi { + export interface IGridSelectionApi { // Methods /** * Unselects All Rows @@ -2827,12 +2838,12 @@ declare module uiGrid { * returns all selected rows as gridRows * @returns {Array} The selected rows */ - getSelectedGridRows(): Array; + getSelectedGridRows(): Array>; /** * Gets selected rows as entities - * @returns {Array} Selected row entities + * @returns {Array} Selected row entities */ - getSelectedRows(): Array; + getSelectedRows(): Array; /** * Selects all rows. Does nothing if multiselect = false * @param {ng.IAngularEvent} event object if raised from event @@ -2845,10 +2856,10 @@ declare module uiGrid { selectAllVisibleRows(event?: ng.IAngularEvent): void; /** * Select row by data - * @param {any} rowEntity gridOptions.data[] array value + * @param {TEntity} rowEntity gridOptions.data[] array value * @param {ng.IAngularEvent} event object if raised from event */ - selectRow(rowEntity: any, event?: ng.IAngularEvent): void; + selectRow(rowEntity: TEntity, event?: ng.IAngularEvent): void; /** * Select the specified row by visible index * (i.e. if you specify row 0 you'll get the first visible row selected). @@ -2872,16 +2883,16 @@ declare module uiGrid { setMultiSelect(multiSelect: boolean): void; /** * Toggles data row as selected or unselected - * @param {any} rowEntity gridOptions.data[] array value + * @param {TEntity} rowEntity gridOptions.data[] array value * @param {ng.IAngularEvent} event object if raised from event */ - toggleRowSelection(rowEntity: any, event?: ng.IAngularEvent): void; + toggleRowSelection(rowEntity: TEntity, event?: ng.IAngularEvent): void; /** * UnSelect the data row - * @param {any} rowEntity gridOptions.data[] array value + * @param {TEntity} rowEntity gridOptions.data[] array value * @param {ng.IAngularEvent} event object if raised from event */ - unSelectRow(rowEntity: any, event?: ng.IAngularEvent): void; + unSelectRow(rowEntity: TEntity, event?: ng.IAngularEvent): void; // Events on: { @@ -2890,7 +2901,7 @@ declare module uiGrid { * @param {ng.IScope} scope grid scope * @param {rowSelectionChangedHandler} handler callback */ - rowSelectionChanged: (scope: ng.IScope, handler: rowSelectionChangedHandler) => void; + rowSelectionChanged: (scope: ng.IScope, handler: rowSelectionChangedHandler) => void; /** * is raised after the row.isSelected state is changed in bulk, * if the enableSelectionBatchEvent option is set to true (which it is by default). @@ -2898,25 +2909,25 @@ declare module uiGrid { * @param {ng.IScope} scope grid scope * @param {rowSelectionChangedBatchHandler} handler callback */ - rowSelectionChangedBatch: (scope: ng.IScope, handler: rowSelectionChangedBatchHandler) => void; + rowSelectionChangedBatch: (scope: ng.IScope, handler: rowSelectionChangedBatchHandler) => void; } } - export interface rowSelectionChangedHandler { + export interface rowSelectionChangedHandler { /** * Callback for row selection changed * @param {IGridRow} row The selected rows * @param {ng.IAngularEvent} event object if raised from event */ - (row: uiGrid.IGridRow, event?: ng.IAngularEvent): void; + (row: uiGrid.IGridRowOf, event?: ng.IAngularEvent): void; } - export interface rowSelectionChangedBatchHandler { + export interface rowSelectionChangedBatchHandler { /** * Callback for row selection changed batch * @param {IGridRow} row The selected rows * @param {ng.IAngularEvent} event object if raised from event */ - (row: Array, event?: ng.IAngularEvent): void; + (row: Array>, event?: ng.IAngularEvent): void; } } @@ -2924,7 +2935,7 @@ declare module uiGrid { /** * ColumnDef for tree feature, these are available to be set using the ui-grid gridOptions.columnDefs */ - export interface IColumnDef { + export interface IColumnDef { /** * A custom function that populates aggregation.rendered. * This is called when a particular aggregation has been fully calculated, and we want to render the value. @@ -2951,7 +2962,7 @@ declare module uiGrid { * @param {IGridRow} row Row objet */ customerTreeAggregationFn?: (aggregation: IGridTreeBaseAggregationObject, fieldValue: any, numValue: number, - row: IGridRow) => void; + row: IGridRowOf) => void; /** * A custom label to use for this aggregation. If providedm, we don't use native i18n */ @@ -2997,7 +3008,7 @@ declare module uiGrid { /** * Tree Base Grid Options */ - export interface IGridOptions { + export interface IGridOptions { /** * If set to true, show the expand/collapse button even if there are no children of a node. * You'd use this if you're planning to dynamically load the children @@ -3026,7 +3037,7 @@ declare module uiGrid { * Defaults to {} * @default {} */ - treeCustomAggregations?: { [index: string]: IGridTreeBaseCustomAggregation; }; + treeCustomAggregations?: { [index: string]: IGridTreeBaseCustomAggregation; }; /** * Number of pixels of indent for the icon at each tree level, wider indents are visually more pleasing, * but will make the tree row header wider @@ -3049,10 +3060,10 @@ declare module uiGrid { treeRowHeaderBaseWidth?: number; } - export interface IGridTreeBaseCustomAggregation { + export interface IGridTreeBaseCustomAggregation { label: string; aggregationFn: (aggregation: IGridTreeBaseAggregationObject, fieldValue: any, numValue: number, - row?: IGridRow) => void; + row?: IGridRowOf) => void; finalizerFn?: (aggregation: IGridTreeBaseAggregationObject) => void; } export interface IGridTreeBaseAggregationObject { @@ -3062,7 +3073,7 @@ declare module uiGrid { rendered?: string; } - export interface IGridTreeBaseApi { + export interface IGridTreeBaseApi { // Methods /** * Collapse all tree rows @@ -3072,13 +3083,13 @@ declare module uiGrid { * collapse the specified row. When you expand the row again, all grandchildren will retain their state * @param {IGridRow} row The row to collapse */ - collapseRow(row: IGridRow): void; + collapseRow(row: IGridRowOf): void; /** * collapse all children of the specified row. When you expand the row again, all grandchildren will be * collapsed * @param {IGridRow} row The row to collapse children of */ - collapseRowChildren(row: IGridRow): void; + collapseRowChildren(row: IGridRowOf): void; /** * Expands all tree rows */ @@ -3087,13 +3098,13 @@ declare module uiGrid { * Expand the immediate children of the specified row * @param {IGridRow} row The row to expand */ - expandRow(row: IGridRow): void; + expandRow(row: IGridRowOf): void; /** * Get the children of the specified row * @param {IGridRow} row The row you want the children of * @returns Array Array of children rows */ - getRowChildren(row: IGridRow): Array; + getRowChildren(row: IGridRowOf): Array>; /** * Get the tree state for this grid, used by the saveState feature Returned treeState as an object * ```{ expandedState: { uid: 'expanded', uid: 'collapsed' } }``` @@ -3111,7 +3122,7 @@ declare module uiGrid { * call expand if row is collapsed, and collapse if it is expanded * @param {IGridRow} row The row to toggle */ - toggleRowTreeState(row: IGridRow): void; + toggleRowTreeState(row: IGridRowOf): void; // Events on: { @@ -3120,7 +3131,7 @@ declare module uiGrid { * @param {ng.IScope} scope Grid scope * @param {rowCollapsedHandler} handler Callback */ - rowCollapsed: (scope: ng.IScope, handler: rowCollapsedHandler) => void; + rowCollapsed: (scope: ng.IScope, handler: rowCollapsedHandler) => void; /** * Raised whenever a row is expanded. * @@ -3131,7 +3142,7 @@ declare module uiGrid { * @param {ng.IScope} scope Grid Scope * @param {rowExpandedHandler} handler Callback */ - rowExpanded: (scope: ng.IScope, handler: rowExpandedHandler) => void; + rowExpanded: (scope: ng.IScope, handler: rowExpandedHandler) => void; } } @@ -3141,20 +3152,22 @@ declare module uiGrid { } } - export interface rowCollapsedHandler { + export interface rowCollapsedHandler { /** * Row Collapsed callback - * @param {IGridRow} row The row that was collapsed. You can also retrieve the grid from this row with row.grid + * @param {IGridRow} row The row that was collapsed. You can also retrieve the grid from this row with + * row.grid */ - (row: IGridRow): void; + (row: IGridRowOf): void; } - export interface rowExpandedHandler { + export interface rowExpandedHandler { /** * Row Expanded callback - * @param {IGridRow} row The row that was expanded. You can also retrieve the grid from this row with row.grid + * @param {IGridRow} row The row that was expanded. You can also retrieve the grid from this row with + * row.grid */ - (row: IGridRow): void; + (row: IGridRowOf): void; } /** @@ -3204,10 +3217,11 @@ declare module uiGrid { // Tree View - export interface IGridApiConstructor { - new (grid: IGridInstance): IGridApi; + export interface IGridApiConstructor { + new (grid: IGridInstanceOf): IGridApiOf; } - export interface IGridApi { + export type IGridApi = IGridApiOf; + export interface IGridApiOf { /** * Registers a new event for the given feature. The event will get a .raise and .on prepended to it * @@ -3260,12 +3274,12 @@ declare module uiGrid { /** * Core Api */ - core: IGridCoreApi; + core: IGridCoreApi; /** * Cell Nav Api */ - cellNav: cellNav.ICellNavApi; + cellNav: cellNav.ICellNavApi; /** * Move Columns Api @@ -3280,12 +3294,12 @@ declare module uiGrid { /** * Edit Api */ - edit: edit.IGridEditApi; + edit: edit.IGridEditApi; /** * Expandable Api */ - expandable: expandable.IGridExpandableApi; + expandable: expandable.IGridExpandableApi; /** * Exporter Api @@ -3295,7 +3309,7 @@ declare module uiGrid { /** * Grouping Api */ - grouping: grouping.IGridGroupingApi; + grouping: grouping.IGridGroupingApi; /** * Importer Api @@ -3305,7 +3319,7 @@ declare module uiGrid { /** * Infinite Scroll Api */ - infiniteScroll: infiniteScroll.IGridInfiniteScrollApi; + infiniteScroll: infiniteScroll.IGridInfiniteScrollApi; /** * Pagination Api @@ -3315,12 +3329,12 @@ declare module uiGrid { /** * Pinning Api */ - pinning: pinning.IGridPinningApi; + pinning: pinning.IGridPinningApi; /** * Grid Row Edit Api */ - rowEdit: rowEdit.IGridRowEditApi; + rowEdit: rowEdit.IGridRowEditApi; /** * Grid Save State Api @@ -3329,19 +3343,19 @@ declare module uiGrid { /** * Selection Api */ - selection: selection.IGridSelectionApi; + selection: selection.IGridSelectionApi; /** * Tree Base Api */ - treeBase: treeBase.IGridTreeBaseApi; + treeBase: treeBase.IGridTreeBaseApi; /** * A grid instance is made available in the gridApi. */ - grid: IGridInstance; + grid: IGridInstanceOf; } - export interface IGridRowConstructor { + export interface IGridRowConstructor { /** * GridRow is the viewModel for one logical row on the grid. * A grid Row is not necessarily a one-to-one relation to gridOptions.data. @@ -3349,13 +3363,15 @@ declare module uiGrid { * @param index the current position of the row in the array * @param reference to the parent grid */ - new(entity: any, index: number, reference: IGridInstance): IGridRow; + new(entity: TEntity, index: number, reference: IGridInstanceOf): IGridRowOf; } - export interface IGridRow extends cellNav.IGridRow, edit.IGridRow, exporter.IGridRow, selection.IGridRow { + export type IGridRow = IGridRowOf; + export interface IGridRowOf extends cellNav.IGridRow, edit.IGridRow, exporter.IGridRow, + selection.IGridRow { /** A reference to an item in gridOptions.data[] */ - entity: any; + entity: TEntity; /** A reference back to the grid */ - grid: IGridInstance; + grid: IGridInstanceOf; /** * height of each individual row. changing the height will flag all * row renderContainers to recalculate their canvas height @@ -3383,7 +3399,7 @@ declare module uiGrid { * Changed to just call the internal function row.clearThisRowInvisible(). * @param row the row we want to clear the invisible flag */ - clearRowInvisible(row: IGridRow): void; + clearRowInvisible(row: IGridRowOf): void; /** * Clears any override on the row visibility, returning it to normal visibility calculations. * Emits the rowsVisibleChanged event @@ -3403,13 +3419,13 @@ declare module uiGrid { * @param col column instance * @returns resulting name that can be evaluated against a row */ - getEntityQualifiedColField(col: IGridColumn): string; + getEntityQualifiedColField(col: IGridColumnOf): string; /** * returns the qualified field name as it exists on scope ie: row.entity.fieldA * @param col column instance * @returns resulting name that can be evaluated on scope */ - getQualifiedColField(col: IGridColumn): string; + getQualifiedColField(col: IGridColumnOf): string; /** * Sets an override on the row that forces it to always be invisible. * Emits the rowsVisibleChanged event if it changed the row visibility. @@ -3419,7 +3435,7 @@ declare module uiGrid { * Changed to just call the internal function row.setThisRowInvisible(). * @param row the row we want to set to invisible */ - setRowInvisible(row: IGridRow): void; + setRowInvisible(row: IGridRowOf): void; /** * Sets an override on the row that forces it to always be invisible. * Emits the rowsVisibleChanged event if it changed the row visibility @@ -3429,7 +3445,7 @@ declare module uiGrid { setThisRowInvisible(reason: string, fromRowsProcessor: boolean): void; } - export interface IGridColumnConstructor { + export interface IGridColumnConstructor { /** * Represents the viewModel for each column. * Any state or methods needed for a Grid Column are defined on this prototype @@ -3437,12 +3453,13 @@ declare module uiGrid { * @param index the current position of the column in the array * @param grid reference to the grid */ - new(gridCol: IColumnDef, index: number, grid: IGridInstance): IGridColumn; + new(gridCol: IColumnDefOf, index: number, grid: IGridInstanceOf): IGridColumnOf; } - export interface IGridColumn { + export type IGridColumn = IGridColumnOf; + export interface IGridColumnOf { /** Column definition */ - colDef: uiGrid.IColumnDef; + colDef: uiGrid.IColumnDefOf; /** * Column name that will be shown in the header. * If displayName is not provided then one is generated using the name. @@ -3472,7 +3489,7 @@ declare module uiGrid { * @param uid The unique and immutable uid we'd like to allocate to this column * @param grid the grid we'd like to create this column in */ - GridColumn(colDef: IColumnDef, uid: number, grid: IGridInstance): void; + GridColumn(colDef: IColumnDefOf, uid: number, grid: IGridInstanceOf): void; /** * Gets the aggregation label from colDef.aggregationLabel if specified or by using i18n, * including deciding whether or not to display based on colDef.aggregationHideLabel. @@ -3510,7 +3527,7 @@ declare module uiGrid { * @param propName the property name we'd like to set * @param defaultValue the value to use if the colDef doesn't provide the setting */ - setPropertyOrDefault(colDef: IColumnDef, propName: string, defaultValue: any): void; + setPropertyOrDefault(colDef: IColumnDefOf, propName: string, defaultValue: any): void; /** Makes the column visible by setting colDef.visible = true */ showColumn(): void; /** @@ -3519,7 +3536,7 @@ declare module uiGrid { * @param isNew whether the column is being newly created, if not we're updating an existing * column, and some items such as the sort shouldn't be copied down */ - updateColumnDef(colDef: IColumnDef, isNew: boolean): void; + updateColumnDef(colDef: IColumnDefOf, isNew: boolean): void; } /** @@ -3527,8 +3544,10 @@ declare module uiGrid { * which would typically be one of many column definitions within the * gridOptions.columnDefs array */ - export interface IColumnDef extends cellNav.IColumnDef, edit.IColumnDef, exporter.IColumnDef, grouping.IColumnDef, - moveColumns.IColumnDef, pinning.IColumnDef, resizeColumns.IColumnDef, treeBase.IColumnDef { + export type IColumnDef = IColumnDefOf; + export interface IColumnDefOf extends cellNav.IColumnDef, edit.IColumnDef, exporter.IColumnDef, + grouping.IColumnDef, moveColumns.IColumnDef, pinning.IColumnDef, resizeColumns.IColumnDef, + treeBase.IColumnDef { /** * defaults to false * if set to true hides the label text in the aggregation footer, so only the value is displayed. @@ -3551,7 +3570,7 @@ declare module uiGrid { * or it can be a function(row,rowRenderIndex, col, colRenderIndex) * that returns a class name */ - cellClass?: string | ICellClassGetter; + cellClass?: string | ICellClassGetter; /** cellFilter is a filter to apply to the content of each cell */ cellFilter?: string; /** @@ -3571,7 +3590,7 @@ declare module uiGrid { * Defaults to false * @default false */ - cellTooltip?: boolean | string | ICellTooltipGetter; + cellTooltip?: boolean | string | ICellTooltipGetter; /** * Column name that will be shown in the header. * If displayName is not provided then one is generated using the name. @@ -3633,7 +3652,7 @@ declare module uiGrid { * footerCellClass can be a string specifying the class to append to a cell or it can be * a function(row,rowRenderIndex, col, colRenderIndex) that returns a class name */ - footerCellClass?: string | IHeaderFooterCellClassGetter; + footerCellClass?: string | IHeaderFooterCellClassGetter; /** footerCellFilter is a filter to apply to the content of the column footer */ footerCellFilter?: string; /** a custom template for the footer for this column. The default is ui-grid/uiGridFooterCell */ @@ -3642,7 +3661,7 @@ declare module uiGrid { * headerCellClass can be a string specifying the class to append to a cell or it can be * a function(row,rowRenderIndex, col, colRenderIndex) that returns a class name */ - headerCellClass?: string | IHeaderFooterCellClassGetter; + headerCellClass?: string | IHeaderFooterCellClassGetter; /** headerCellFilter is a filter to apply to the content of the column header */ headerCellFilter?: string; /** a custom template for the header for this column. The default is ui-grid/uiGridHeaderCell */ @@ -3657,7 +3676,7 @@ declare module uiGrid { * if a static string then shows that static string. * @default false */ - headerTooltip?: boolean | string | IHeaderTooltipGetter; + headerTooltip?: boolean | string | IHeaderTooltipGetter; /** sets the maximum column width */ maxWidth?: number; /** used to add menu items to a column. Refer to the tutorial on this functionality */ @@ -3709,18 +3728,19 @@ declare module uiGrid { width?: number | string; } - export interface ICellClassGetter { - (gridRow?: IGridRow, gridCol?: IGridColumn, colRenderIndex?: number): string; + export interface ICellClassGetter { + (gridRow?: IGridRowOf, gridCol?: IGridColumnOf, colRenderIndex?: number): string; } - export interface ICellTooltipGetter { - (gridRow: IGridRow, gridCol: IGridColumn): string; + export interface ICellTooltipGetter { + (gridRow: IGridRowOf, gridCol: IGridColumnOf): string; } - export interface IHeaderTooltipGetter { - (gridCol: IGridColumn): string; + export interface IHeaderTooltipGetter { + (gridCol: IGridColumnOf): string; } - export interface IHeaderFooterCellClassGetter { - (gridRow: IGridRow, rowRenderIndex: number, gridCol: IGridColumn, colRenderIndex: number): string; + export interface IHeaderFooterCellClassGetter { + (gridRow: IGridRowOf, rowRenderIndex: number, gridCol: IGridColumnOf, colRenderIndex: number) + : string; } export interface IMenuItem { /** controls the title that is displayed in the menu */