# ColumnDef

Fields, allowed values, and APIs that use ColumnDef.

Canonical: https://grid.syidax.com/docs/types/ColumnDef/

<a id="definition"></a>

## Type definition

A question mark (?) marks an optional field; readonly marks a value you should not change directly. A union (|) accepts one of the listed forms. Functions are callbacks that Grid invokes at the relevant point.

```typescript
export interface ColumnDef<TData = GridData, TValue = unknown, TContext = unknown> {
  field: GridFieldPath<TData>;
  colId?: string;
  headerName?: string;
  headerTooltip?: string;
  sortable?: boolean;
  sort?: 'asc' | 'desc' | null;
  sortIndex?: number;
  filter?:
    | ColumnFilterDecl
    | string
    | GridFilterDefinition<TData, TValue, unknown, TContext>;
  valueGetter?: GridCallback<[ValueGetterParams<TData, TValue, TContext>], TValue> | string;
  formula?: string;
  valueFormatter?: GridCallback<[ValueFormatterParams<TData, TValue, TContext>], string> | string;
  tooltipField?: GridFieldPath<TData>;
  tooltipValueGetter?: GridCallback<[ValueGetterParams<TData, TValue, TContext>], unknown> | string;
  cellRenderer?:
    | string
    | CellRenderer<TData, TValue>
    | GridRendererDefinition<TData, TValue, TContext>;
  cellRendererMeta?: Record<string, unknown>;
  cellEditor?: GridCellEditorDeclaration<TData, TValue, TContext>;
  floatingFilterComponent?:
    | string
    | GridFloatingFilterDefinition<unknown, TContext>;
  cellClass?:
    | string
    | string[]
    | GridCallback<[CellCallbackParams<TData, TValue, TContext>], string>;
  cellClassRules?: Record<
    string,
    GridCallback<[CellCallbackParams<TData, TValue, TContext>], boolean> | string
  >;
  cellStyle?:
    | Record<string, string | number>
    | GridCallback<
        [CellCallbackParams<TData, TValue, TContext>],
        Record<string, string | number> | null | undefined
      >
    | ReadonlyArray<
        | Record<string, string | number>
        | GridCallback<
            [CellCallbackParams<TData, TValue, TContext>],
            Record<string, string | number> | null | undefined
          >
      >;
  width?: number;
  minWidth?: number;
  maxWidth?: number;
  flex?: number;
  resizable?: boolean;
  reorderable?: boolean;
  pinned?: 'left' | 'right' | null;
  columnGroupShow?: 'open' | 'closed';
  aggFunc?: 'sum' | 'avg' | 'min' | 'max' | 'count' | string;
  hidden?: boolean;
  hide?: boolean;
  editable?: boolean;
  editor?: 'text' | 'number' | 'date' | 'select' | 'checkbox' | 'textarea' | 'autocomplete' | 'largeText';
  valueParser?: GridCallback<[ValueParserParams<TData, TValue, TContext>], TValue>;
  valueSetter?: GridCallback<
    [ValueSetterParams<TData, TValue, TContext>],
    boolean | void
  >;
  comparator?: GridCallback<[TValue, TValue, Readonly<TData>, Readonly<TData>], number>;
  options?: ReadonlyArray<{ value: unknown; label: string; disabled?: boolean }>;
  min?: number | Date | string;
  max?: number | Date | string;
  step?: number;
  decimals?: number;
  nullable?: boolean;
  allowEmpty?: boolean;
  storeAs?: 'date' | 'iso';
  rows?: number;
  maxRows?: number;
  cols?: number;
  maxLength?: number;
  rowDrag?: boolean;
  wrapText?: boolean;
  autoHeight?: boolean;
  rowSpan?: (params: SyGridRowSpanParams<TData>) => number;
  colSpan?: (params: SyGridColSpanParams<TData>) => number;
}
```

<a id="used-by"></a>

## APIs using this type

- [columnDefs](https://grid.syidax.com/docs/options/columnDefs.md) — Defines column data fields, headings, sizes, visibility, and editing. Include column groups to create multi-level headers.
- [defaultColDef](https://grid.syidax.com/docs/options/defaultColDef.md) — Defaults shared by all columns. Override individual values in columnDefs for specific columns.

<a id="parents"></a>

## Contracts containing this type

- [CellCallbackParams](https://grid.syidax.com/docs/types/CellCallbackParams.md)
- [ContextMenuContext](https://grid.syidax.com/docs/types/ContextMenuContext.md)
- [CsvExportColumn](https://grid.syidax.com/docs/types/CsvExportColumn.md)
- [DetailGridOptions](https://grid.syidax.com/docs/types/DetailGridOptions.md)
- [GridColumnDefinition](https://grid.syidax.com/docs/types/GridColumnDefinition.md)
- [GridColumnGroupDef](https://grid.syidax.com/docs/types/GridColumnGroupDef.md)
- [GridColumnMenuContext](https://grid.syidax.com/docs/types/GridColumnMenuContext.md)
- [GridColumnRef](https://grid.syidax.com/docs/types/GridColumnRef.md)
- [PdfExportColumn](https://grid.syidax.com/docs/types/PdfExportColumn.md)
- [SyGridColSpanParams](https://grid.syidax.com/docs/types/SyGridColSpanParams.md)
- [SyGridRowSpanParams](https://grid.syidax.com/docs/types/SyGridRowSpanParams.md)
- [ValueFormatterParams](https://grid.syidax.com/docs/types/ValueFormatterParams.md)
- [ValueGetterParams](https://grid.syidax.com/docs/types/ValueGetterParams.md)
- [ValueParserParams](https://grid.syidax.com/docs/types/ValueParserParams.md)
- [ValueSetterParams](https://grid.syidax.com/docs/types/ValueSetterParams.md)

<a id="related"></a>

## Related types

- [GridData](https://grid.syidax.com/docs/types/GridData.md)
- [GridFieldPath](https://grid.syidax.com/docs/types/GridFieldPath.md)
- [ColumnFilterDecl](https://grid.syidax.com/docs/types/ColumnFilterDecl.md)
- [GridFilterDefinition](https://grid.syidax.com/docs/types/GridFilterDefinition.md)
- [GridCallback](https://grid.syidax.com/docs/types/GridCallback.md)
- [ValueGetterParams](https://grid.syidax.com/docs/types/ValueGetterParams.md)
- [ValueFormatterParams](https://grid.syidax.com/docs/types/ValueFormatterParams.md)
- [CellRenderer](https://grid.syidax.com/docs/types/CellRenderer.md)
- [GridRendererDefinition](https://grid.syidax.com/docs/types/GridRendererDefinition.md)
- [GridCellEditorDeclaration](https://grid.syidax.com/docs/types/GridCellEditorDeclaration.md)
- [GridFloatingFilterDefinition](https://grid.syidax.com/docs/types/GridFloatingFilterDefinition.md)
- [CellCallbackParams](https://grid.syidax.com/docs/types/CellCallbackParams.md)
- [ValueParserParams](https://grid.syidax.com/docs/types/ValueParserParams.md)
- [ValueSetterParams](https://grid.syidax.com/docs/types/ValueSetterParams.md)
- [SyGridRowSpanParams](https://grid.syidax.com/docs/types/SyGridRowSpanParams.md)
- [SyGridColSpanParams](https://grid.syidax.com/docs/types/SyGridColSpanParams.md)
