UNPKG

3.31 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 { ColDef } from "../entities/colDef";
6import { IRowModel } from "./iRowModel";
7import { RowNode } from "../entities/rowNode";
8import { IComponent } from "./iComponent";
9export interface IFilter {
10 /** This is used to show the filter icon in the header. If true, the filter icon will be shown. */
11 isFilterActive(): boolean;
12 /** The grid will ask each active filter, in turn, whether each row in the grid passes. If any
13 filter fails, then the row will be excluded from the final set. The method is provided a
14 params object with attributes node (the rodNode the grid creates that wraps the data) and data
15 (the data object that you provided to the grid for that row). */
16 doesFilterPass(params: IDoesFilterPassParams): boolean;
17 /** Gets the filter state for storing */
18 getModel(): any;
19 /** Restores the filter state. */
20 setModel(model: any): void;
21 /** Gets called when new rows are inserted into the grid. If the filter needs to change it's state
22 after rows are loaded, it can do it here. */
23 onNewRowsLoaded?(): void;
24 /** If using React or Angular 2, returns the underlying component instance, so you can call methods
25 * on it if you want. */
26 getFrameworkComponentInstance?(): any;
27 /**
28 * Optional method used by ag-Grid when rendering floating filters and there isn't a floating filter
29 * associated for this filter, this will happen if you create a custom filter and NOT a custom floating
30 * filter.
31 */
32 getModelAsString?(model: any): string;
33 /**
34 * Optional method used by ag-Grid when rendering floating filters.
35 *
36 * If this method IS NOT IMPLEMENTED, when the floating filter changes, ag-Grid will automatically call
37 * IFilterParams.filterChangedCallback, triggering the filtering of the data based on the changes from
38 * the floating filter. For the simplest cases this is enough.
39 *
40 * IF IT IS IMPLEMENTED. ag-Grid will delegate into this method the responsibility of calling
41 * IFilterParams.filterChangedCallback. This is useful if additional logic is necessary, for instance
42 * ag-Grid uses this in addition with the applyNow flag to handle the apply button logic in the default
43 * ag-Grid filters.
44 *
45 * change: The exact same object passed on FloatingFilter.onFloatingFilterChanged
46 */
47 onFloatingFilterChanged?(change: any): void;
48}
49export interface SerializedFilter {
50 filterType: string;
51}
52export interface IFilterComp extends IFilter, IComponent<IFilterParams> {
53}
54export interface IDoesFilterPassParams {
55 node: RowNode;
56 data: any;
57}
58export interface IFilterParams {
59 clearButton?: boolean;
60 applyButton?: boolean;
61 newRowsAction?: string;
62 column: Column;
63 colDef: ColDef;
64 rowModel: IRowModel;
65 filterChangedCallback: () => void;
66 filterModifiedCallback: () => void;
67 valueGetter: (rowNode: RowNode) => any;
68 doesRowPassOtherFilter: (rowNode: RowNode) => boolean;
69 context: any;
70 $scope: any;
71 filterOptions?: string[];
72 defaultOption?: string;
73 textFormatter?: (from: string) => string;
74}