Skip to main content

api.getColumn(id)

Description

Gets an object with the column configuration

Usage

api.getColumn(id): object;

Parameters

  • id - the id of a column

Returns

The method returns an object with the column parameters:

{
id: string,
width: number,
flexgrow?: number,
sort?: boolean,
left?: number,
editor?: string | any,
setter?: (obj: {}, value: Value) => void,
getter?: (obj: {}) => Value,
hidden?: boolean,
options?: [],
header?: string | [],
footer?: string | [],
resize?: boolean,
treetoggle?: boolean,
cell?: any,
css?: string,
tooltip?: boolean | (obj: any) => any
}

Example

The example below shows how to output the "city" column configuration to the console:

import { useEffect, useRef } from 'react';
import { getData } from "./common/data";
import { Grid } from "@wx/react-grid";

const { data, columns } = getData();

export default function App() {
const api = useRef(null);

useEffect(() => {
if (api.current) {
const column = api.current.getColumn("city");
console.log("Column:", column);
}
}, [api.current]);

return <Grid data={data} columns={columns} api={api} />;
}

Related articles: