UNPKG

@adaptabletools/adaptable

Version:

Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

220 lines (219 loc) 7.03 kB
import { FilterActionOnDataChange } from '../AdaptableState/Common/FilterActionOnDataChange'; import { BaseContext } from '../../types'; import { AdaptableColumn } from '../AdaptableState/Common/AdaptableColumn'; import { SystemAlertPredicateId, SystemFilterPredicateId } from '../../types'; import { StrictExtract } from '../Utilities/Extensions/TypeExtensions'; import { AdaptableColumnContext } from '../AdaptableState/Common/AdaptableColumnContext'; import { IRowNode } from 'ag-grid-enterprise'; /** * Options for managing Column & Grid Filters in AdapTable */ export interface FilterOptions<TData = any> { /** * Options for managing Column Filters */ columnFilterOptions?: ColumnFilterOptions; /** * Options for managing the Grid Filter */ gridFilterOptions?: GridFilterOptions; /** * Clear Grid and Column Filters when AdapTable loads * * @defaultValue true * @gridInfoItem * @noCodeItem */ clearFiltersOnStartUp?: boolean; /** * Provide custom values (or sorting / count info) when using the `In` Filter * @param context * @returns */ customInFilterValues?: (context: CustomInFilterValuesContext<TData>) => Promise<InFilterValueInfo[]> | InFilterValueInfo[]; /** * When to re-filter grid after data changes: 'Always', 'Never' or 'Throttle' (with a delay value) * * @defaultValue 'Always' */ filterActionOnDataChange?: FilterActionOnDataChange; /** * Allow filtering on Calculated & FreeText columns * * @defaultValue true * @gridInfoItem */ enableFilterOnSpecialColumns?: boolean; /** * Configures whether Rows will be evaluated when filtering * * @param context * @returns boolean */ isRowFilterable?: (context: IsRowFilterableContext) => boolean; /** * Show Date Picker (or Date Input) in Filter controls * @gridInfoItem * @noCodeItem * @defaultValue true */ showDatePicker?: boolean; /** * Use Adaptable's Column & Grid Filters in preference to AG Grid's filtering * * @defaultValue true * @noCodeItem */ useAdaptableFiltering?: boolean; } /** * Options for managing Column Filtering in AdapTable */ export interface ColumnFilterOptions<TData = any> { /** * Make Column Header distinctive for filtered columns, helps users see currently filtered columns * * @defaultValue true * @gridInfoItem * @noCodeItem */ indicateFilteredColumns?: boolean; /** * Apply selected Column Filters as soon as they are clicked; if false an Apply Filter button is displayed * * @defaultValue true * @gridInfoItem * @noCodeItem */ autoApplyColumnFilter?: boolean; /** * Default filter type for numeric Columns * * @defaultValue Equals * @gridInfoItem */ defaultNumericColumnFilter?: StrictExtract<SystemFilterPredicateId, 'GreaterThan' | 'LessThan' | 'Equals' | 'NotEquals' | 'In'> | ((column: AdaptableColumn) => StrictExtract<SystemFilterPredicateId, 'GreaterThan' | 'LessThan' | 'Equals' | 'NotEquals' | 'In'>); /** * Default filter type for text Columns * * @defaultValue Contains * @gridInfoItem */ defaultTextColumnFilter?: StrictExtract<SystemFilterPredicateId, 'Is' | 'IsNot' | 'Contains' | 'NotContains' | 'StartsWith' | 'EndsWith' | 'Regex' | 'In'> | ((column: AdaptableColumn) => StrictExtract<SystemFilterPredicateId, 'Is' | 'IsNot' | 'Contains' | 'NotContains' | 'StartsWith' | 'EndsWith' | 'Regex' | 'In'>); /** * Default filter type for date Columns * * @defaultValue On * @gridInfoItem */ defaultDateColumnFilter?: StrictExtract<SystemFilterPredicateId, 'After' | 'Before' | 'On' | 'NotOn' | 'In'> | ((column: AdaptableColumn) => StrictExtract<SystemFilterPredicateId, 'After' | 'Before' | 'On' | 'NotOn' | 'In'>); /** * Hides Dropdown in Quick Filter Bar for a given Column * * @defaultValue undefined */ hideQuickFilterDropdown?: (adaptableColumnContext: AdaptableColumnContext<TData>) => boolean; /** * Hides Input in Quick Filter Bar for a given Column * * @defaultValue undefined */ hideQuickFilterInput?: (adaptableColumnContext: AdaptableColumnContext<TData>) => boolean; /** * Height of Quick Filter Bar (if not provided, AG Grid default is used) * * @defaultValue null * @gridInfoItem */ quickFilterHeight?: number; /** * Display Quick Filter Bar between Column Header and Grid (provided its been setup) * @defaultValue true * @noCodeItem */ showQuickFilter?: boolean; /** * Shortcut Keys to activate a Quick Filter Predicate */ quickFilterWildcards?: Partial<Record<SystemAlertPredicateId, string[]>>; /** * Time to wait (in ms) before Filter Bar reacts to new value * @defaultValue 250 * @gridInfoItem */ quickFilterDebounce?: number; } /** * Options for managing the Grid Filter in AdapTable */ export interface GridFilterOptions<TData = any> { /** * Which UI Components can be used to edit a Grid Filter: Expression Editor, Query Builder (or both) * * @defaultValue ['ExpressionEditor', 'QueryBuilder'] */ availableFilterEditors?: GridFilterEditors; } /** * Context used for setting whether a Row can be Column Filtered */ export interface IsRowFilterableContext<TData = any> extends BaseContext { /** * The Row Node about to be evaluated */ rowNode: IRowNode; /** * The data in the Row Node */ data: TData; } /** * Information about items in the IN Column Filter */ export interface InFilterValueInfo { /** * The value of the item being shown */ value: any; /** * Item's label */ label?: string; /** * Whether item is currently selected */ isSelected?: boolean; /** * How many times the item appears in the column */ count?: number; /** * Whether the item is currently visible in the Grid (i.e. in filtered rows) */ visible?: boolean; } /** * Context used when providing values for the IN Column Filter */ export interface CustomInFilterValuesContext<TData = any> extends AdaptableColumnContext { /** * Default list of values that will be displayed */ defaultValues: Required<InFilterValueInfo>[]; /** * Default values but Sorted based on Column's sort */ sortedValues: Required<InFilterValueInfo>[]; /** * Search text in the IN Filter component - used when filtering on server */ currentSearchValue: string; } /** * List of Editors that can be used when creating the Grid Filter */ export type GridFilterEditors = GridFilterEditor[]; /** * Editor to use for Grid Filter: 'ExpressionEditor' or 'QueryBuilder' */ export type GridFilterEditor = 'ExpressionEditor' | 'QueryBuilder';