diff --git a/slickgrid/SlickGrid.d.ts b/slickgrid/SlickGrid.d.ts index 850a9a117..741124ffa 100644 --- a/slickgrid/SlickGrid.d.ts +++ b/slickgrid/SlickGrid.d.ts @@ -217,7 +217,7 @@ declare module Slick { * @extends Slick.NonDataItem * @constructor */ - export class Group extends NonDataRow { + export class Group extends NonDataRow { constructor(); @@ -240,7 +240,7 @@ declare module Slick { * @property value * @type {Object} */ - public value: T; + public value: any; /*** * Formatted display value of the group. @@ -261,21 +261,21 @@ declare module Slick { * @property totals * @type {GroupTotals} */ - public totals: GroupTotals; + public totals: GroupTotals; /** * Rows that are part of the group. * @property rows * @type {Array} */ - public rows: R[]; + public rows: T[]; /** * Sub-groups that are part of the group. * @property groups * @type {Array} */ - public groups: Group[]; + public groups: Group[]; /** * A unique key used to identify the group. This key can be used in calls to DataView @@ -292,7 +292,7 @@ declare module Slick { * @param group {Group} Group instance to compare to. * todo: this is on the prototype (NonDataRow()) instance, not Group, maybe doesn't matter? */ - public equals(group: Group): boolean; + public equals(group: Group): boolean; } /*** @@ -304,7 +304,7 @@ declare module Slick { * @extends Slick.NonDataItem * @constructor */ - export class GroupTotals extends NonDataRow { + export class GroupTotals extends NonDataRow { constructor(); @@ -313,7 +313,7 @@ declare module Slick { * @param group * @type {Group} */ - public group: Group; + public group: Group; } @@ -690,14 +690,86 @@ declare module Slick { } export interface DataProvider { - getItem(index: number): T; + /** + * Returns the number of data items in the set. + */ getLength(): number; + + /** + * Returns the item at a given index. + * @param index + */ + getItem(index: number): T; + + /** + * Returns the metadata for the item at a given index (optional). + * @param index + */ + getItemMetadata?(index: number): RowMetadata; } export interface SlickData { // todo ? might be able to leave as empty } + export interface RowMetadata { + /** + * One or more (space-separated) CSS classes to be added to the entire row. + */ + cssClasses?: string; + + /** + * Whether or not any cells in the row can be set as "active". + */ + focusable?: boolean; + + /** + * Whether or not a row or any cells in it can be selected. + */ + selectable?: boolean; + + /** + * Metadata related to individual columns + */ + columns?: { + /** + * Metadata indexed by column id + */ + [index: string]: ColumnMetadata; + /** + * Metadata indexed by column index + */ + [index: number]: ColumnMetadata; + } + } + + export interface ColumnMetadata { + /** + * Whether or not a cell can be set as "active". + */ + focusable?: boolean; + + /** + * Whether or not a cell can be selected. + */ + selectable?: boolean; + + /** + * A custom cell formatter. + */ + formatter?: Formatter; + + /** + * A custom cell editor. + */ + editor?: Slick.Editors.Editor; + + /** + * Number of columns this cell will span. Can also contain "*" to indicate that the cell should span the rest of the row. + */ + colspan?: number|string; + } + /** * Selecting cells in SlickGrid is handled by a selection model. * Selection models are controllers responsible for handling user interactions and notifying subscribers of the changes in the selection. Selection is represented as an array of Slick.Range objects. @@ -1489,8 +1561,7 @@ declare module Slick { public fastSort(field: string, ascending: boolean): void; public fastSort(field: Function, ascending: boolean): void; // todo: typeof(field), should be the same callback as Array.sort public reSort(): void; - public setGrouping(groupingInfos: GroupingOptions[]): void; - public setGrouping(groupingInfo: GroupingOptions): void; + public setGrouping(groupingInfos: GroupingOptions | GroupingOptions[]): void; public getGrouping(): GroupingOptions[]; /** @@ -1528,7 +1599,7 @@ declare module Slick { * the 'high' setGrouping. */ public expandGroup(...varArgs: string[]): void; - public getGroups(): Group[]; + public getGroups(): Group[]; public getIdxById(id: string): number; public getRowById(): T; public getItemById(id: any): T; @@ -1546,7 +1617,7 @@ declare module Slick { public getLength(): number; public getItem(index: number): T; - public getItemMetadata(index?: number): void; + public getItemMetadata(index: number): RowMetadata; public onRowCountChanged: Slick.Event; public onRowsChanged: Slick.Event; @@ -1554,16 +1625,16 @@ declare module Slick { } export interface GroupingOptions { - getter: Function; // todo - formatter: Formatter; - comparer: (a:any, b:any) => any; // todo - predefinedValues: any[]; // todo - aggregators: Aggregators.Aggregator[]; - aggregateEmpty: boolean; - aggregateCollapsed: boolean; - aggregateChildGroups: boolean; - collapsed: boolean; - displayTotalsRow: boolean; + getter?: ((item?: T) => any) | string; + formatter?: (item?: T) => string; + comparer?: (a: Group, b: Group) => number; + predefinedValues?: any[]; // todo + aggregators?: Aggregators.Aggregator[]; + aggregateEmpty?: boolean; + aggregateCollapsed?: boolean; + aggregateChildGroups?: boolean; + collapsed?: boolean; + displayTotalsRow?: boolean; } export interface PagingOptions { @@ -1596,7 +1667,7 @@ declare module Slick { public field: string; public init(): void; public accumulate(item: T): void; - public storeResult(groupTotals: GroupTotals): void; // todo "R" + public storeResult(groupTotals: GroupTotals): void; } export class Avg extends Aggregator { @@ -1633,29 +1704,8 @@ declare module Slick { export class GroupItemMetadataProvider { public init(): void; public destroy(): void; - public getGroupRowMetadata(): GroupRowMetadata; - public getTotalsRowMetadata(): TotalsRowMetadata; - } - - export interface GroupRowMetadata { - selectable: boolean; - focusable: boolean; - cssClasses: string; - columns: { - 0: { - colspan: string; - formatter: Formatter; - editor: Slick.Editors.Editor; - } - }; - } - - export interface TotalsRowMetadata { - selectable: boolean; - focusable: boolean; - cssClasses: string; - formatter: Formatter; - editor: Slick.Editors.Editor; + public getGroupRowMetadata(item?: Group): RowMetadata; + public getTotalsRowMetadata(item?: GroupTotals): RowMetadata; } export interface GroupItemMetadataProviderOptions {