From 2a04a33b8fc79f79fa358fd341f1b4669f369bf3 Mon Sep 17 00:00:00 2001 From: Raymond Suelzer Date: Fri, 17 Jul 2015 16:04:30 -0400 Subject: [PATCH] added some api extensions, fixed some types added core, pagination, selection to GridAPI. Also fixed a few types that were incorrect, missing, or should have been nullable. --- ui-grid/ui-grid.d.ts | 78 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 69 insertions(+), 9 deletions(-) diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index f27700e70..0d7f4e7fe 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -88,11 +88,11 @@ declare module uiGrid { } export interface IGridOptions { aggregationCalcThrottle?: number; - appScopeProvider?: ng.IScope; + appScopeProvider?: ng.IScope | Object; columnDefs?: IColumnDef; columnFooterHeight?: number; columnVirtualizationThreshold?: number; - data?: Array; + data?: Array | string; enableColumnMenus?: boolean; enableFiltering?: boolean; enableHorizontalScrollbar?: boolean; @@ -109,7 +109,7 @@ declare module uiGrid { gridFooterTemplate?: string; gridMenuCustomItems?: Array; gridMenuShowHideColumns?: boolean; - gridMenuTitleFilter: (title: string) => ng.IPromise | string; + gridMenuTitleFilter?: (title: string) => ng.IPromise | string; headerTemplate?: string; horizontalScrollThreshold?: number; infiniteScrollDown?: boolean; @@ -130,12 +130,52 @@ declare module uiGrid { useExternalSorting?: boolean; virtualizationThreshold?: number; wheelScrollThrottle?: number; - getRowIdentity(): any; - rowEquality(entityA: IGridRow, entityB: IGridRow): boolean; - rowIdentity(): any; + getRowIdentity?(): any; + rowEquality?(entityA: IGridRow, entityB: IGridRow): boolean; + rowIdentity? (): any; + totalItems?: number; } + + + export interface IGridCoreApi { + on: { + sortChanged: (scope: ng.IScope, handler: (grid: IGridInstance, sortColumns: IColumnDef[]) => void) => void; + columnVisiblityChanged: (scope: ng.IScope, handler: (grid: IGridColumn) => void) => void; + } + } + + export interface IGridSelectionApi { + toggleRowSelection: (rowEntity: IGridRow, event?: Event) => void; + selectRow: (rowEntity: IGridRow, event?: Event) => void; + selectRowByVisibleIndex: (rowEntity: number, event?: Event) => void; + unSelectRow: (rowEntity: IGridRow, event?: Event) => void; + selectAllRows: (event?: Event) => void; + selectAllVisibleRows: (event?: Event) => void; + clearSelectedRows: (event?: Event) => void; + getSelectedRows: () => IGridRow[]; + getSelectedGridRows: () => IGridRow[]; + setMultiSelect: (multiSelect: boolean) => void; + setModifierKeysToMultiSelect: (multiSelect: boolean) => void; + getSelectAllState: () => boolean; + on: { + rowSelectionChanged: (scope: ng.IScope, handler: (row: IGridRow, event?: Event) => void) => void; + rowSelectionChangedBatch: (scope, handler: (row: IGridRow[], event?: Event) => void) => void; + } + } + + export interface IGridPaginationApi { + getPage: () => number; + getTotalPages: () => number; + nextPage: () => void; + previousPage: () => void; + seek: () => void; + on: { + paginationChanged: (scope, handler: (newPage: number, pageSize: number) => void) => void; + } + } + export interface IGridApiConstructor { - new(grid: IGridInstance): IGridApi; + new (grid: IGridInstance): IGridApi; } export interface IGridApi { /** @@ -186,6 +226,26 @@ declare module uiGrid { * @param callBackFn function to execute */ suppressEvents(listenerFuncs: Function | Array, callBackFn: Function): void; + + /** + * Core Api + */ + core: IGridCoreApi; + + /** + * Selection api + */ + + selection: IGridSelectionApi; + + + /** + * Pagination api + */ + pagination: IGridPaginationApi; + + + } export interface IGridRowConstructor { /** @@ -410,7 +470,7 @@ declare module uiGrid { * in this case your function needs to accept the full set of visible rows, * and return a value that should be shown */ - aggregationType: number | Function; + aggregationType?: number | Function; /** * cellClass can be a string specifying the class to append to a cell * or it can be a function(row,rowRenderIndex, col, colRenderIndex) @@ -604,7 +664,7 @@ declare module uiGrid { leaveOpen?: boolean; } export interface ISortInfo { - direction?: number; + direction?: string; ignoreSort?: boolean; priority?: number; }