hide-column
Description
Fires when hiding a columnUsage
"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 hiddenmode- (optional) if set to true, hides a column; if false, a column is showneventSource- (optional) the name of the Grid action that triggeredhide-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: