The column API interface that is available in the grid [[apiRef]]. TODO: Differentiate interfaces based on the plan

interface GridColumnApi {
    getAllColumns: (() => GridStateColDef[]);
    getColumn: ((field: string) => GridStateColDef);
    getColumnIndex: ((field: string, useVisibleColumns?: boolean) => number);
    getColumnIndexRelativeToVisibleColumns: ((field: string) => number);
    getColumnPosition: ((field: string) => number);
    getVisibleColumns: (() => GridStateColDef[]);
    setColumnVisibility: ((field: string, isVisible: boolean) => void);
    setColumnVisibilityModel: ((model: GridColumnVisibilityModel) => void);
    setColumnWidth: ((field: string, width: number) => void);
    updateColumns: ((cols: GridColDef[]) => void);
}

Hierarchy (view full)

Properties

getAllColumns: (() => GridStateColDef[])

Returns an array of [[GridColDef]] containing all the column definitions.

Type declaration

    • (): GridStateColDef[]
    • Returns GridStateColDef[]

      An array of [[GridStateColDef]].

getColumn: ((field: string) => GridStateColDef)

Returns the [[GridColDef]] for the given field.

Type declaration

    • (field): GridStateColDef
    • Parameters

      • field: string

        The column field.

      Returns GridStateColDef

      The [[GridStateColDef]].

getColumnIndex: ((field: string, useVisibleColumns?: boolean) => number)

Returns the index position of a column. By default, only the visible columns are considered. Pass false to useVisibleColumns to consider all columns.

Type declaration

    • (field, useVisibleColumns?): number
    • Parameters

      • field: string

        The column field.

      • OptionaluseVisibleColumns: boolean

        Determines if all columns or the visible ones should be considered. Default is true.

      Returns number

      The index position.

getColumnIndexRelativeToVisibleColumns: ((field: string) => number)

Gets the index of a column relative to the columns that are reachable by scroll.

Type declaration

    • (field): number
    • Parameters

      • field: string

        The column field.

      Returns number

      The index of the column.

getColumnPosition: ((field: string) => number)

Returns the left-position of a column relative to the inner border of the grid.

Type declaration

    • (field): number
    • Parameters

      • field: string

        The column field.

      Returns number

      The position in pixels.

getVisibleColumns: (() => GridStateColDef[])

Returns the currently visible columns.

Type declaration

    • (): GridStateColDef[]
    • Returns GridStateColDef[]

      An array of [[GridStateColDef]].

setColumnVisibility: ((field: string, isVisible: boolean) => void)

Changes the visibility of the column referred by field.

Type declaration

    • (field, isVisible): void
    • Parameters

      • field: string

        The column to change visibility.

      • isVisible: boolean

        Pass true to show the column, or false to hide it. Default is false

      Returns void

setColumnVisibilityModel: ((model: GridColumnVisibilityModel) => void)

Sets the column visibility model to the one given by model.

Type declaration

setColumnWidth: ((field: string, width: number) => void)

Updates the width of a column.

Type declaration

    • (field, width): void
    • Parameters

      • field: string

        The column field.

      • width: number

        The new width.

      Returns void

updateColumns: ((cols: GridColDef[]) => void)

Updates the definition of multiple columns at the same time.

Type declaration

    • (cols): void
    • Parameters

      • cols: GridColDef[]

        The new column [[GridColDef]] objects.

      Returns void