ag-grid-community
Version:
Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue
269 lines (268 loc) • 15.3 kB
TypeScript
import type { IAgEventEmitter } from 'ag-stack';
import type { ColumnState } from '../columns/columnStateUtils';
import { BeanStub } from '../context/beanStub';
import type { BeanCollection } from '../context/context';
import type { ColumnEvent, ColumnEventType } from '../events';
import type { GridOptionsService } from '../gridOptionsService';
import type { Column, ColumnEventName, ColumnGroup, ColumnGroupShowType, ColumnHighlightPosition, ColumnInstanceId, ColumnPinnedType, HeaderColumnId, ProvidedColumnGroup } from '../interfaces/iColumn';
import type { IRowNode } from '../interfaces/iRowNode';
import type { SortDef, SortDirection, SortType } from '../interfaces/iSort';
import type { AgColumnGroup } from './agColumnGroup';
import type { AgProvidedColumnGroup } from './agProvidedColumnGroup';
import type { AbstractColDef, ColAggFunc, ColDef, ColDefField, ColSpanFunc, ColumnFunctionCallbackParams, HeaderLocation, RefData, RowSpanFunc, ValueFormatterFunc, ValueGetterFunc } from './colDef';
import type { AgShowValuesAsResolved, ShowValuesAsDefResolved, ShowValuesAsResolved, ShowValuesAsResult } from './colDef-showValuesAs';
export declare function getNextColInstanceId(): ColumnInstanceId;
export declare const isColumn: (col: Column | ColumnGroup | ProvidedColumnGroup) => col is AgColumn;
/**
* Redirects a pivot result column to its underlying value column for non-group, non-pinned (leaf) rows,
* so value get/set reads the real source value. Pinned rows are excluded — their data is keyed by pivot
* column ID. Only the deliberate consumers (pivot edit, API reads, pivot aggregation) need this; the hot
* read path (`getValueFromData`) does not.
* @internal AG_GRID_INTERNAL - Not for public use. Can change / be removed at any time.
*/
export declare const _resolvePivotColumnForRow: (column: AgColumn, rowNode: IRowNode) => AgColumn;
/** Origin of an `AgColumn`. `user` = application-supplied ColDef; others = grid-generated.
* @internal AG_GRID_INTERNAL - Not for public use. Can change / be removed at any time. */
export type ColKind = 'user' | 'auto-group' | 'selection' | 'row-number' | 'hierarchy';
/** @internal AG_GRID_INTERNAL - Not for public use. Can change / be removed at any time. */
export declare class AgColumn<TValue = any> extends BeanStub<ColumnEventName> implements Column, IAgEventEmitter<ColumnEventName> {
colDef: ColDef<any, TValue>;
userProvidedColDef: ColDef<any, TValue> | null;
readonly colId: string;
readonly primary: boolean;
readonly colKind: ColKind;
readonly isColumn: true;
readonly instanceId: ColumnInstanceId;
/** Sanitised version of the column id */
readonly colIdSanitised: string;
aggFunc: ColAggFunc;
isCalculatedCol: boolean;
field: ColDefField<any, TValue> | undefined;
/** Cached split of a dotted `field` (`field.split('.')`); `null` when not dotted / dot-notation suppressed.
* Non-null doubles as the "field contains dots" indicator. Read per cell via `_getValueUsingDotPath`. */
fieldPath: string[] | null;
valueGetter: string | ValueGetterFunc<any, TValue> | undefined;
allowFormula: boolean;
showRowGroup: string | boolean | undefined;
pivotValueColumn: AgColumn | null | undefined;
valueFormatter: string | ValueFormatterFunc<any, TValue> | undefined;
refData: RefData | undefined;
enableCellChangeFlash: boolean | undefined;
/** Read per cell when the colSpan/rowSpan feature is used (`getColSpan`/`getRowSpan`). */
colSpan: ColSpanFunc<any, TValue> | undefined;
rowSpan: RowSpanFunc<any, TValue> | undefined;
/** Read per cell on calculated columns (`formulaService.ensureCellFormula`/`fetchRawValue`). */
calculatedExpression: string | undefined;
/** Current rendered width in px. Writes must go through `setActualWidth` for min/max clamping and the `widthChanged` event. */
actualWidth: number;
minWidth: number;
private maxWidth;
flex: number | null;
pinned: ColumnPinnedType;
left: number | null;
oldLeft: number | null;
/** User intent: should this column be shown if display rules allow it. */
visible: boolean;
/** Whether this column is in the displayed (rendered) columns — kept in lockstep with `allColsIndex >= 0` */
displayed: boolean;
filterActive: boolean;
sortDef: SortDef;
sortIndex: number | null | undefined;
autoHeaderHeight: number | null;
tooltipEnabled: boolean;
tooltipFieldContainsDots: boolean;
private frameworkEventListenerService;
private colEventSvc;
/** Most recent build token that claimed this col — used to detect "already used in this refresh". */
buildToken: number;
/** 0-based index in `VisibleColsService.allCols` (displayed, visual order — RTL reversed), stamped each refresh. `-1` = not displayed. */
allColsIndex: number;
/** `true` while in `ColumnModel.colsList` (live cols, hidden included); `false` when only in
* `colsById` — a pivot **primary** parked while a pivot result shows. Set by `refreshCols`. */
inColsList: boolean;
/** 1-based `aria-colindex`: position in `colsList` reordered `[left, center, right]` (hidden included). `0` = not in `colsList`. */
ariaColIndex: number;
/** 0-based index in `ColumnModel.colsList` (stamped lazily by `ensureColsListIndex` for O(1) ordered reads);
* `-1` until first stamped / when not in colsList. In pivot, parked primaries keep their pre-pivot index. */
colsListIndex: number;
moving: boolean;
resizing: boolean;
menuVisible: boolean;
highlighted: ColumnHighlightPosition | null;
formulaRef: string | null;
/** The column's "Show Values As" config resolved once on colDef change (built-in modes merged with user config).
* Tri-state: the config object when configured, `null` when explicitly disabled (`colDef.showValuesAsDef: null`),
* `undefined` when unconfigured. The active mode is a lookup into it. */
showValuesAsDef: ShowValuesAsDefResolved | null | undefined;
/** Resolved active "Show Values As" mode for this column (precomputed by the enterprise service), or `null`
* when none. `showValuesAs.type` is the active mode; the active mode is owned by column state. */
showValuesAs: AgShowValuesAsResolved | null;
/** colId this column sits immediately after in display order. Order restoration seats new cols after
* this anchor — handles anchors absent from the tree (e.g. auto-group col) and stacks same-anchor adds
* newest-first. `undefined` = not anchored. Column-kind agnostic (currently set by the calc-column contributor). */
anchoredToColId: string | undefined;
private lastLeftPinned;
private firstRightPinned;
rowGroupActive: boolean;
/** Position in `rowGroupColsSvc.columns` when {@link rowGroupActive}; else stale — always pair the read with a `rowGroupActive` check. */
rowGroupActiveIndex: number;
pivotActive: boolean;
/** Position in `pivotColsSvc.columns` when {@link pivotActive}; else stale — always pair the read with a `pivotActive` check. */
pivotActiveIndex: number;
aggregationActive: boolean;
/** Position in `valueColsSvc.columns` when {@link aggregationActive}; else stale — always pair the read with an `aggregationActive` check. */
aggregationActiveIndex: number;
/** The display group col that shows this (source) column; set by `showRowGroupCols` on refresh */
showRowGroupCol: AgColumn | null;
parent: AgColumnGroup | null;
originalParent: AgProvidedColumnGroup | null;
/** Public so the free `getAvailableSortTypes` sort helper can cache on the column; nulled in {@link setColDef}. */
cachedSortTypes: Set<SortType> | null;
constructor(colDef: ColDef<any, TValue>, userProvidedColDef: ColDef<any, TValue> | null, colId: string, primary: boolean, colKind: ColKind);
destroy(): void;
getInstanceId(): ColumnInstanceId;
private initState;
/** Called when user provides an alternative colDef. Returns whether the merged colDef differed (false = nothing changed). */
setColDef(colDef: ColDef<any, TValue>, userProvidedColDef: ColDef<any, TValue> | null, source: ColumnEventType): boolean;
/** Re-apply `def` to a reused column. Stateful attrs are only (re)applied when the user authored the
* definitions (`newColDefs`); an internal rebuild (e.g. calc-col add) must leave live state intact. */
reapplyColDef(def: ColDef, source: ColumnEventType, newColDefs: boolean): void;
getUserProvidedColDef(): ColDef<any, TValue> | null;
getParent(): AgColumnGroup | null;
getOriginalParent(): AgProvidedColumnGroup | null;
postConstruct(): void;
private initDotNotation;
private initMinAndMaxWidths;
private initTooltip;
resetActualWidth(source: ColumnEventType): void;
private calculateColInitialWidth;
isEmptyGroup(): false;
isRowGroupDisplayed(colId: string): boolean;
isPrimary(): boolean;
isFilterAllowed(): boolean;
isFieldContainsDots(): boolean;
isTooltipEnabled(): boolean;
isTooltipFieldContainsDots(): boolean;
getHighlighted(): ColumnHighlightPosition | null;
private getColEventSvc;
__addEventListener<T extends ColumnEventName>(eventType: T, listener: (params: ColumnEvent<T>) => void): void;
__removeEventListener<T extends ColumnEventName>(eventType: T, listener: (params: ColumnEvent<T>) => void): void;
/**
* PUBLIC USE ONLY: for internal use within AG Grid use the `__addEventListener` and `__removeEventListener` methods.
*/
addEventListener<T extends ColumnEventName>(eventType: T, userListener: (params: ColumnEvent<T>) => void): void;
/**
* PUBLIC USE ONLY: for internal use within AG Grid use the `__addEventListener` and `__removeEventListener` methods.
*/
removeEventListener<T extends ColumnEventName>(eventType: T, userListener: (params: ColumnEvent<T>) => void): void;
createColumnFunctionCallbackParams(rowNode: IRowNode): ColumnFunctionCallbackParams;
isSuppressNavigable(rowNode: IRowNode): boolean;
isCellEditable(rowNode: IRowNode): boolean;
isSuppressFillHandle(): boolean;
isAutoHeight(): boolean;
isAutoHeaderHeight(): boolean;
isRowDrag(rowNode: IRowNode): boolean;
isDndSource(rowNode: IRowNode): boolean;
isCellCheckboxSelection(rowNode: IRowNode): boolean;
isSuppressPaste(rowNode: IRowNode): boolean;
/** Mirror the hot-path colDef fields onto the column so per-cell reads avoid a megamorphic colDef load.
* `field`/`fieldPath` are set by {@link initDotNotation} (they depend on `suppressFieldDotNotation`). */
private initColDefHotFields;
private initCalculatedColumnState;
isResizable(): boolean;
isColumnFunc(rowNode: IRowNode, value?: boolean | ((params: ColumnFunctionCallbackParams) => boolean) | null): boolean;
isMoving(): boolean;
getSort(): SortDirection;
/** Returns null if no sort direction applied */
getSortDef(): SortDef | null;
setSortDef(sortDef: SortDef): void;
isSortable(): boolean;
/** @deprecated v32 use col.getSort() === 'asc */
isSortAscending(): boolean;
/** @deprecated v32 use col.getSort() === 'desc */
isSortDescending(): boolean;
/** @deprecated v32 use col.getSort() === undefined */
isSortNone(): boolean;
/** @deprecated v32 use col.getSort() !== undefined */
isSorting(): boolean;
getSortIndex(): number | null | undefined;
isMenuVisible(): boolean;
getAggFunc(): ColAggFunc;
getShowValuesAs<TOut extends ShowValuesAsResult = any>(): ShowValuesAsResolved<any, TValue, TOut> | null;
getShowValuesAsDef(): ShowValuesAsDefResolved<any, TValue> | null;
getLeft(): number | null;
getOldLeft(): number | null;
getRight(): number;
setLeft(left: number | null, source: ColumnEventType): void;
isFilterActive(): boolean;
/** @deprecated v33 Use `api.isColumnHovered(column)` instead. */
isHovered(): boolean;
setFirstRightPinned(firstRightPinned: boolean, source: ColumnEventType): void;
setLastLeftPinned(lastLeftPinned: boolean, source: ColumnEventType): void;
isFirstRightPinned(): boolean;
isLastLeftPinned(): boolean;
isPinned(): boolean;
isPinnedLeft(): boolean;
isPinnedRight(): boolean;
getPinned(): ColumnPinnedType;
setVisible(visible: boolean, source: ColumnEventType): void;
isVisible(): boolean;
isSpanHeaderHeight(): boolean;
/** Returns the first parent that is not a padding group. */
getFirstRealParent(): AgProvidedColumnGroup | null;
getColumnGroupPaddingInfo(): {
numberOfParents: number;
isSpanningTotal: boolean;
};
getColDef(): ColDef<any, TValue>;
getDefinition(): AbstractColDef<any, TValue>;
getColumnGroupShow(): ColumnGroupShowType | undefined;
getColId(): string;
getDisplayName(location?: HeaderLocation): string;
getId(): string;
getUniqueId(): HeaderColumnId;
getActualWidth(): number;
getAutoHeaderHeight(): number | null;
/** Returns true if the header height has changed */
setAutoHeaderHeight(height: number): boolean;
getColSpan(rowNode: IRowNode): number;
getRowSpan(rowNode: IRowNode): number;
setActualWidth(actualWidth: number, source: ColumnEventType, silent?: boolean): void;
fireColumnWidthChangedEvent(source: ColumnEventType): void;
isGreaterThanMax(width: number): boolean;
getMinWidth(): number;
getMaxWidth(): number;
getFlex(): number | null;
isRowGroupActive(): boolean;
isPivotActive(): boolean;
isAnyFunctionActive(): boolean;
isAnyFunctionAllowed(): boolean;
isValueActive(): boolean;
isAllowPivot(): boolean;
isAllowValue(): boolean;
isAllowRowGroup(): boolean;
isAllowFormula(): boolean;
dispatchColEvent(type: ColumnEventName, source: ColumnEventType, additionalEventAttributes?: any): void;
dispatchStateUpdatedEvent(key: keyof ColumnState): void;
}
/** Convert input into a SortDef: a valid SortDef passes through, otherwise direction and type are normalised. */
export declare const getSortDefFromInput: (input?: unknown) => SortDef;
export declare const getSortingOrder: (gos: GridOptionsService, column: AgColumn) => SortDef[];
export declare const isSortDirectionValid: (maybeSortDir: unknown) => maybeSortDir is SortDirection;
export declare const isSortTypeValid: (maybeSortType: unknown) => maybeSortType is SortType;
export declare const _isSortDefValid: (maybeSortDef: unknown) => maybeSortDef is SortDef;
export declare const normalizeSortDirection: (sortDirectionLike?: unknown) => SortDirection;
/** @internal AG_GRID_INTERNAL - Not for public use. Can change / be removed at any time. */
export declare const _normalizeSortType: (sortTypeLike?: unknown) => SortType;
type SortDefOverride = () => SortDef | null | undefined;
/** @internal AG_GRID_INTERNAL - Not for public use. Can change / be removed at any time. */
export declare const _getDisplaySortForColumn: (column: AgColumn, beans: BeanCollection, override?: SortDefOverride) => {
isDefaultSortAllowed: boolean;
isAbsoluteSortAllowed: boolean;
isAbsoluteSort: boolean;
isDefaultSort: boolean;
isAscending: boolean;
isDescending: boolean;
direction: SortDirection;
};
export {};