diff --git a/ui-grid/ui-grid-tests.ts b/ui-grid/ui-grid-tests.ts index f34a2eabe..5e1497594 100644 --- a/ui-grid/ui-grid-tests.ts +++ b/ui-grid/ui-grid-tests.ts @@ -116,11 +116,17 @@ var gridOptions: uiGrid.IGridOptions = { }) } } -var rowEntityToScrollTo = {anObject: 'inGridOptionsData'}; -var columnDefToScrollTo: uiGrid.IColumnDef; -gridInstance.scrollTo(); -gridInstance.scrollTo(rowEntityToScrollTo); -gridInstance.scrollTo(rowEntityToScrollTo, columnDefToScrollTo); +interface AnotherEntity { + anObject: string +} +var anotherGridInstance: uiGrid.IGridInstance; +var rowEntityToScrollTo = { + anObject: 'inGridOptionsData' +}; +var columnDefToScrollTo: uiGrid.IColumnDef; +anotherGridInstance.scrollTo(); +anotherGridInstance.scrollTo(rowEntityToScrollTo); +anotherGridInstance.scrollTo(rowEntityToScrollTo, columnDefToScrollTo); var selectedRowEntities: Array = gridApi.selection.getSelectedRows(); -var selectedGridRows: Array = gridApi.selection.getSelectedGridRows(); +var selectedGridRows: Array> = gridApi.selection.getSelectedGridRows(); diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index effd0f16c..3b63f6855 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. @@ -289,7 +289,7 @@ declare module uiGrid { * @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 @@ -860,7 +860,7 @@ declare module uiGrid { * TODO: if a filter is active then we can't just set it to visible? * @param {any} 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 @@ -931,7 +931,7 @@ declare module uiGrid { * @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: IColumnDef): 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. @@ -1129,7 +1129,7 @@ declare module uiGrid { * @param {any} 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: { @@ -1390,7 +1390,7 @@ declare module uiGrid { * @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; } /** @@ -1401,7 +1401,7 @@ declare module uiGrid { * keystrokes on some complex editors */ export interface beginCellEditHandler { - (rowEntity: any, colDef: IColumnDef, triggerEvent: JQueryEventObject): void; + (rowEntity: TEntity, colDef: IColumnDef, triggerEvent: JQueryEventObject): void; } /** @@ -1410,7 +1410,7 @@ declare module uiGrid { * @param {IColumnDef} colDef The column that was edited */ export interface cancelCellEditHandler { - (rowEntity: any, colDef: IColumnDef): void; + (rowEntity: TEntity, colDef: IColumnDef): void; } /** @@ -1480,7 +1480,7 @@ declare module uiGrid { * Toggle a specific row * @param {any} rowEntity The data entity for the row you want to expand */ - toggleRowExpansion(rowEntity: any): void; + toggleRowExpansion(rowEntity: TEntity): void; // Events on: { @@ -1528,7 +1528,7 @@ declare module uiGrid { * @default null * @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, @@ -1536,7 +1536,7 @@ declare module uiGrid { * use exporterAllDataFn instead. * @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 ',' @@ -1973,7 +1973,7 @@ declare module uiGrid { * @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 */ - importerDataAddCallback?: (grid: IGridInstance, newObjects: Array) => void; + importerDataAddCallback?: (grid: IGridInstance, 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. @@ -2010,7 +2010,7 @@ declare module uiGrid { * @returns {any} The modified object * @default angular.identity */ - importerObjectCallback?: (grid: IGridInstance, newObject: any) => any; + importerObjectCallback?: (grid: IGridInstance, 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 @@ -2488,7 +2488,7 @@ declare module uiGrid { * and clearing the error flag and the dirty flag * @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, @@ -2496,7 +2496,7 @@ declare module uiGrid { * wrapped with $interval or $timeout. * @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 +2519,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 */ - (rowEntity: Array): void; + (rowEntity: Array): void; } } @@ -2827,12 +2827,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 */ - getSelectedRows(): Array; + getSelectedRows(): Array; /** * Selects all rows. Does nothing if multiselect = false * @param {ng.IAngularEvent} event object if raised from event