Skip to main content

hide-column

Description

Fires when hiding a column

Usage

"hide-column": ({
id: string,
mode?: boolean,
eventSource?: string,
}) => boolean|void;

Parameters

The callback of the action takes an object with the following parameters:

  • id - (required) the ID of a column that is hidden
  • mode - (optional) if set to true, hides a column; if false, a column is shown
  • eventSource - (optional) the name of the Grid action that triggered hide-column

Returning false from the event handler will block hiding a column.

Example

import { useRef } from "react";
import { getData } from "./common/data";
import { Grid } from "@svar-ui/react-grid";
import { Button } from "@svar-ui/react-core";

export default function Example() {
const { data, columns } = getData();

const apiRef = useRef(null);

const hideColumn = () => {
// Use the Grid API via ref in React
apiRef.current?.exec("hide-column", { id: "firstName", mode: true });
};

return (
<>
<Button onClick={hideColumn} type="primary">Hide</Button>

<Grid data={data} columns={columns} ref={apiRef} />
</>
);
}

Related articles: