slickgrid: some fixes

This commit is contained in:
Koloto
2015-09-11 15:23:36 +03:00
parent 03bab3b4e2
commit bab64ac3f0
+97 -47
View File
@@ -217,7 +217,7 @@ declare module Slick {
* @extends Slick.NonDataItem
* @constructor
*/
export class Group<T, R> extends NonDataRow {
export class Group<T extends SlickData> 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<T, R>;
public totals: GroupTotals<T>;
/**
* 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<T, R>[];
public groups: Group<T>[];
/**
* 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<T, R>): boolean;
public equals(group: Group<T>): boolean;
}
/***
@@ -304,7 +304,7 @@ declare module Slick {
* @extends Slick.NonDataItem
* @constructor
*/
export class GroupTotals<T, R> extends NonDataRow {
export class GroupTotals<T> extends NonDataRow {
constructor();
@@ -313,7 +313,7 @@ declare module Slick {
* @param group
* @type {Group}
*/
public group: Group<T, R>;
public group: Group<T>;
}
@@ -690,14 +690,86 @@ declare module Slick {
}
export interface DataProvider<T extends SlickData> {
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<T>;
}
export interface SlickData {
// todo ? might be able to leave as empty
}
export interface RowMetadata<T> {
/**
* 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<T>;
/**
* Metadata indexed by column index
*/
[index: number]: ColumnMetadata<T>;
}
}
export interface ColumnMetadata<T extends SlickData> {
/**
* 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<T>;
/**
* A custom cell editor.
*/
editor?: Slick.Editors.Editor<T>;
/**
* 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<T>[]): void;
public setGrouping(groupingInfo: GroupingOptions<T>): void;
public setGrouping(groupingInfos: GroupingOptions<T> | GroupingOptions<T>[]): void;
public getGrouping(): GroupingOptions<T>[];
/**
@@ -1528,7 +1599,7 @@ declare module Slick {
* the 'high' setGrouping.
*/
public expandGroup(...varArgs: string[]): void;
public getGroups(): Group<T, any>[];
public getGroups(): Group<T>[];
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<T>;
public onRowCountChanged: Slick.Event<OnRowCountChangedEventData>;
public onRowsChanged: Slick.Event<OnRowsChangedEventData>;
@@ -1554,16 +1625,16 @@ declare module Slick {
}
export interface GroupingOptions<T> {
getter: Function; // todo
formatter: Formatter<T>;
comparer: (a:any, b:any) => any; // todo
predefinedValues: any[]; // todo
aggregators: Aggregators.Aggregator<T>[];
aggregateEmpty: boolean;
aggregateCollapsed: boolean;
aggregateChildGroups: boolean;
collapsed: boolean;
displayTotalsRow: boolean;
getter?: ((item?: T) => any) | string;
formatter?: (item?: T) => string;
comparer?: (a: Group<T>, b: Group<T>) => number;
predefinedValues?: any[]; // todo
aggregators?: Aggregators.Aggregator<T>[];
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<T, any>): void; // todo "R"
public storeResult(groupTotals: GroupTotals<T>): void;
}
export class Avg<T> extends Aggregator<T> {
@@ -1633,29 +1704,8 @@ declare module Slick {
export class GroupItemMetadataProvider<T extends Slick.SlickData> {
public init(): void;
public destroy(): void;
public getGroupRowMetadata(): GroupRowMetadata<T>;
public getTotalsRowMetadata(): TotalsRowMetadata<T>;
}
export interface GroupRowMetadata<T extends Slick.SlickData> {
selectable: boolean;
focusable: boolean;
cssClasses: string;
columns: {
0: {
colspan: string;
formatter: Formatter<T>;
editor: Slick.Editors.Editor<T>;
}
};
}
export interface TotalsRowMetadata<T extends Slick.SlickData> {
selectable: boolean;
focusable: boolean;
cssClasses: string;
formatter: Formatter<T>;
editor: Slick.Editors.Editor<T>;
public getGroupRowMetadata(item?: Group<T>): RowMetadata<T>;
public getTotalsRowMetadata(item?: GroupTotals<T>): RowMetadata<T>;
}
export interface GroupItemMetadataProviderOptions {