UNPKG

4.84 kBTypeScriptView Raw
1// Type definitions for ag-grid v18.1.2
2// Project: http://www.ag-grid.com/
3// Definitions by: Niall Crosby <https://github.com/ag-grid/>
4import { Column } from "./entities/column";
5import { ColumnController } from "./columnController/columnController";
6import { RowNode } from "./entities/rowNode";
7import { ValueService } from "./valueService/valueService";
8import { GridOptionsWrapper } from "./gridOptionsWrapper";
9import { ExportParams, ProcessCellForExportParams, ProcessHeaderForExportParams } from "./exportParams";
10import { ColumnGroupChild } from "./entities/columnGroupChild";
11/**
12 * This interface works in conjuction with the GridSerializer. When serializing a grid, an instance that implements this interface
13 * must be passed in, the serializer will call back to the provided methods and finally call to parse to obtain the final result
14 * of the serialization.
15 *
16 * The lifecycle of a serializer with a GridSerializingSession is as follows.
17 *
18 * --1 Call to prepare method. An opportunity to do any required work before the call to accumulate data for the rows are about to happen.
19 * --2 Call to the row methods as the serializer loops through the different rows of the grid will call these methods so that the data
20 * can be accumulated. The methods. if there is relevant data will be called in the following order:
21 * a) addCustomHeader
22 * b) onNewHeaderGroupingRow
23 * c) onNewHeader
24 * d) onNewBodyRow
25 * e) addCustomFooter
26 * IF ANY OF THIS METHODS RETURN A ROW ACCUMULATOR, YOU CAN EXPECT THE SERIALIZER TO CALL ON THAT ACCUMULATOR WITH THE DATA FOR THAT ROW
27 * IMMEDIATELY AFTER IT HAS RECEIVED THE OBJECT AND BEFORE IT CALLS YOU TO OBTAIN A NEW ROW ACCUMULATOR
28 * --3 Call to parse method. This method is the last one to be called and is expected to return whatever accumulated
29 * parsed string is to be returned as a result of the serialization
30 *
31 * This interface is closely related to the RowAccumulator and RowSpanningAccumulator interfaces as every time a new row is about
32 * to be created a new instances of RowAccumulator or RowSpanningAccumulator need to be provided.
33
34 */
35export interface GridSerializingSession<T> {
36 /**
37 * INITIAL METHOD
38 */
39 prepare(columnsToExport: Column[]): void;
40 /**
41 * ROW METHODS
42 */
43 addCustomHeader(customHeader: T): void;
44 onNewHeaderGroupingRow(): RowSpanningAccumulator;
45 onNewHeaderRow(): RowAccumulator;
46 onNewBodyRow(): RowAccumulator;
47 addCustomFooter(customFooter: T): void;
48 /**
49 * FINAL RESULT
50 */
51 parse(): string;
52}
53export interface RowAccumulator {
54 onColumn(column: Column, index: number, node?: RowNode): void;
55}
56export interface RowSpanningAccumulator {
57 onColumn(header: string, index: number, span: number): void;
58}
59export declare abstract class BaseGridSerializingSession<T> implements GridSerializingSession<T> {
60 columnController: ColumnController;
61 valueService: ValueService;
62 gridOptionsWrapper: GridOptionsWrapper;
63 processCellCallback: (params: ProcessCellForExportParams) => string;
64 processHeaderCallback: (params: ProcessHeaderForExportParams) => string;
65 cellAndHeaderEscaper: (rawValue: string) => string;
66 constructor(columnController: ColumnController, valueService: ValueService, gridOptionsWrapper: GridOptionsWrapper, processCellCallback?: (params: ProcessCellForExportParams) => string, processHeaderCallback?: (params: ProcessHeaderForExportParams) => string, cellAndHeaderEscaper?: (rawValue: string) => string);
67 abstract prepare(columnsToExport: Column[]): void;
68 abstract addCustomHeader(customHeader: T): void;
69 abstract addCustomFooter(customFooter: T): void;
70 abstract onNewHeaderGroupingRow(): RowSpanningAccumulator;
71 abstract onNewHeaderRow(): RowAccumulator;
72 abstract onNewBodyRow(): RowAccumulator;
73 abstract parse(): string;
74 extractHeaderValue(column: Column): string;
75 extractRowCellValue(column: Column, index: number, type: string, node?: RowNode): any;
76 private getHeaderName(callback, column);
77 private createValueForGroupNode(node);
78 private processCell(rowNode, column, value, processCellCallback, type);
79}
80export declare class GridSerializer {
81 private displayedGroupCreator;
82 private columnController;
83 private rowModel;
84 private pinnedRowModel;
85 private selectionController;
86 private balancedColumnTreeBuilder;
87 private gridOptionsWrapper;
88 serialize<T>(gridSerializingSession: GridSerializingSession<T>, params?: ExportParams<T>): string;
89 recursivelyAddHeaderGroups<T>(displayedGroups: ColumnGroupChild[], gridSerializingSession: GridSerializingSession<T>): void;
90 private doAddHeaderHeader<T>(gridSerializingSession, displayedGroups);
91}
92export declare enum RowType {
93 HEADER_GROUPING = 0,
94 HEADER = 1,
95 BODY = 2,
96}