UNPKG

@adaptabletools/adaptable-cjs

Version:

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

390 lines (389 loc) 10.8 kB
import { Column } from 'ag-grid-enterprise'; import { AdaptableColumnGroup, BaseContext, Layout } from '../types'; /** * Options related to managing Columns in Adaptable. */ export interface ColumnOptions { /** * Provide an alternative Friendly Name for a Column * @defaultValue undefined */ columnFriendlyName?: (columnFriendlyNameContext: ColumnFriendlyNameContext) => string | undefined; /** * Provide a custom Header Name for a Table or Pivot Column */ columnHeader?: (context: ColumnHeaderContext) => string; /** * Optional list of Column Types - used for Scope and creating Special Columns * @defaultValue Empty Array */ columnTypes?: string[] | ((context: ColumnTypesContext) => string[]); /** * Log warning to console if AdapTable cannot find a column * * @defaultValue true * @gridInfoItem * @noCodeItem */ showMissingColumnsWarning?: boolean; /** * Appends the name of the Column Group to a Column's Friendly Name * * @defaultValue false * @gridInfoItem * @noCodeItem */ addColumnGroupToColumnFriendlyName?: boolean; } /** * Common properties for Column Header Context */ export interface BaseColumnHeaderContext extends BaseContext { /** * The default header name for the column */ defaultHeaderName: string; /** * The mame of the current Layout */ currentLayoutName: string; /** * The type (table/pivot) of the current Layout */ currentLayoutType: 'table' | 'pivot'; /** * The current Layout */ currentLayout: Layout; } export interface AutoGroupColumnHeaderContext extends BaseColumnHeaderContext { /** * Auto-generated Group Column when GroupDisplayType is `single` column */ columnType: 'autoGroupColumn'; /** * Technical ID of the Column */ columnId: string; /** * IDs of the Columns that are grouped */ groupedColumnIds: string[]; } export interface RowGroupColumnHeaderContext extends BaseColumnHeaderContext { /** * Group Columns - see `TableLayout.RowGroupedColumns` or `PivotLayout.PivotGroupedColumns` */ columnType: 'groupColumn'; /** * Technical ID of the Column */ columnId: string; /** * ID of the grouped Column */ groupColumnId: string; } export interface TableColumnHeaderContext extends BaseColumnHeaderContext { /** * Table Column - see `TableLayout.TableColumns` */ columnType: 'tableColumn'; /** * Technical ID of the Column */ columnId: string; /** * Optional Aggregation function of the Column - see `TableLayout.TableAggregationColumns` */ aggregation?: string; } export interface TableColumnGroupHeaderContext extends BaseColumnHeaderContext { /** * Column Group - see https://www.ag-grid.com/javascript-data-grid/column-groups/ */ columnType: 'tableColumnGroup'; /** * Technical ID of the Column Group - see `ColGroupDef.groupId` */ groupId: string; /** * IDs of the Column Group children - see `ColGroupDef.children` */ childrenColumnIds: string[]; /** * State of the Column Group */ state: 'expanded' | 'collapsed'; } export interface PivotColumnGroupHeaderContext extends BaseColumnHeaderContext { /** * Pivot Column - see `PivotLayout.PivotColumns` */ columnType: 'pivotColumnGroup'; /** * Technical ID of the generated Column Group */ groupId: string; /** * Pivot Keys for the current Column Group */ pivotKeys: string[]; /** * State of the Column Group */ state: 'expanded' | 'collapsed'; } export interface PivotAggregationColumnHeaderContext extends BaseColumnHeaderContext { /** * Pivot Aggregation Column - see `PivotLayout.PivotAggregationColumns` */ columnType: 'pivotAggregationColumn'; /** * Technical ID of the generated Column */ columnId: string; /** * Current Pivot Keys */ pivotKeys: string[]; /** * ID of the Aggregated Column - see `PivotLayout.PivotAggregationColumns` */ aggregatedColumnId: string; /** * Aggregation function of the Column - see `PivotLayout.PivotAggregationColumns.AggregationColumnValue` */ aggregation: string; } export interface PivotGrandTotalHeaderContext extends BaseColumnHeaderContext { /** * Pivot Grand Total - see `PivotLayout.PivotGrandTotal` */ columnType: 'pivotGrandTotal'; /** * ID of the Aggregated Column - see `PivotLayout.PivotAggregationColumns` */ aggregatedColumnId: string; /** * Aggregation function of the Column - see `PivotLayout.PivotAggregationColumns.AggregationColumnValue` */ aggregation: string; } export interface PivotColumnTotalHeaderContext extends BaseColumnHeaderContext { /** * Pivot Column Total - see `PivotLayout.PivotColumnTotal` */ columnType: 'pivotColumnTotal'; /** * Current Pivot Keys */ pivotKey: string; /** * ID of the Pivot Column - see `PivotLayout.PivotColumns` */ pivotColumnId: string; /** * Aggregation function of the Column - see `PivotLayout.PivotAggregationColumns.AggregationColumnValue` */ aggregation: string; } export interface PivotAggregationTotalHeaderContext extends BaseColumnHeaderContext { /** * Pivot Aggregation Total Column - see `PivotLayout.PivotAggregationColumns.TotalColumn` */ columnType: 'pivotAggregationTotal'; /** * ID of the Aggregated Column - see `PivotLayout.PivotAggregationColumns` */ aggregatedColumnId: string; /** * Aggregation function of the Column - see `PivotLayout.PivotAggregationColumns.AggregationColumnValue` */ aggregation: string; /** * ID of the Pivot Column - see `PivotLayout.PivotColumns` */ pivotColumnId: string; /** * Current Pivot Keys */ pivotKey: string; } export type ColumnHeaderContext = TableColumnHeaderContext | TableColumnGroupHeaderContext | AutoGroupColumnHeaderContext | RowGroupColumnHeaderContext | PivotColumnGroupHeaderContext | PivotAggregationColumnHeaderContext | PivotGrandTotalHeaderContext | PivotColumnTotalHeaderContext | PivotAggregationTotalHeaderContext; export type ColumnHeaderContextOld = BaseColumnHeaderContext & ({ /** * Auto-generated Group Column when GroupDisplayType is `single` column */ columnType: 'autoGroupColumn'; /** * Technical ID of the Column */ columnId: string; /** * IDs of the Columns that are grouped */ groupedColumnIds: string[]; } | { /** * Group Columns - see `TableLayout.RowGroupedColumns` or `PivotLayout.PivotGroupedColumns` */ columnType: 'groupColumn'; /** * Technical ID of the Column */ columnId: string; /** * ID of the grouped Column */ groupColumnId: string; } | { /** * Table Column - see `TableLayout.TableColumns` */ columnType: 'tableColumn'; /** * Technical ID of the Column */ columnId: string; /** * Optional Aggregation function of the Column - see `TableLayout.TableAggregationColumns` */ aggregation?: string; } | { /** * Column Group - see https://www.ag-grid.com/javascript-data-grid/column-groups/ */ columnType: 'tableColumnGroup'; /** * Technical ID of the Column Group - see `ColGroupDef.groupId` */ groupId: string; /** * IDs of the Column Group children - see `ColGroupDef.children` */ childrenColumnIds: string[]; /** * State of the Column Group */ state: 'expanded' | 'collapsed'; } | { /** * Pivot Column - see `PivotLayout.PivotColumns` */ columnType: 'pivotColumnGroup'; /** * Technical ID of the generated Column Group */ groupId: string; /** * Pivot Keys for the current Column Group */ pivotKeys: string[]; /** * State of the Column Group */ state: 'expanded' | 'collapsed'; } | { /** * Pivot Aggregation Column - see `PivotLayout.PivotAggregationColumns` */ columnType: 'pivotAggregationColumn'; /** * Technical ID of the generated Column */ columnId: string; /** * Current Pivot Keys */ pivotKeys: string[]; /** * ID of the Aggregated Column - see `PivotLayout.PivotAggregationColumns` */ aggregatedColumnId: string; /** * Aggregation function of the Column - see `PivotLayout.PivotAggregationColumns.AggregationColumnValue` */ aggregation: string; } | { /** * Pivot Grand Total - see `PivotLayout.PivotGrandTotal` */ columnType: 'pivotGrandTotal'; /** * ID of the Aggregated Column - see `PivotLayout.PivotAggregationColumns` */ aggregatedColumnId: string; /** * Aggregation function of the Column - see `PivotLayout.PivotAggregationColumns.AggregationColumnValue` */ aggregation: string; } | { /** * Pivot Column Total - see `PivotLayout.PivotColumnTotal` */ columnType: 'pivotColumnTotal'; /** * Current Pivot Keys */ pivotKey: string; /** * ID of the Pivot Column - see `PivotLayout.PivotColumns` */ pivotColumnId: string; /** * Aggregation function of the Column - see `PivotLayout.PivotAggregationColumns.AggregationColumnValue` */ aggregation: string; } | { /** * Pivot Aggregation Total Column - see `PivotLayout.PivotAggregationColumns.TotalColumn` */ columnType: 'pivotAggregationTotal'; /** * ID of the Aggregated Column - see `PivotLayout.PivotAggregationColumns` */ aggregatedColumnId: string; /** * Aggregation function of the Column - see `PivotLayout.PivotAggregationColumns.AggregationColumnValue` */ aggregation: string; /** * ID of the Pivot Column - see `PivotLayout.PivotColumns` */ pivotColumnId: string; /** * Current Pivot Keys */ pivotKey: string; }); /** * Context used when setting a Column Friendly Name */ export interface ColumnFriendlyNameContext extends BaseContext { /** * Id of the Column */ colId: string; /** * AG Grid Display Name */ displayName: string; /** * AG Grid ColDef for the Column */ agColumn: Column; /** * Column Group Information */ columnGroup: AdaptableColumnGroup; } /** * Context used when retrieving Column Types */ export interface ColumnTypesContext extends BaseContext { /** * Current Column Types */ types: string[]; }