delete-row
Description
Fires when deleting a rowUsage
"delete-row": ({
id: string | number,
eventSource?: string,
}) => boolean | void;
Parameters
The callback of the action takes an object with the following parameters:
-
id- (required) the ID of a row that is deleted -
eventSource- (optional) the name of the Grid action that triggereddelete-row
Returning false from the event handler will prevent deleting rows.
Example
import { useRef } from "react";
import { getData } from "./common/data";
import { Grid } from "@svar-ui/react-grid";
import { Button } from "@svar-ui/react-core";
const Example = () => {
const { data, columns } = getData();
const apiRef = useRef(null);
const deleteRow = () => {
apiRef.current?.exec("delete-row", {
id: 17,
});
};
return (
<>
<Button onClick={deleteRow} type="primary">Delete Row</Button>
<Grid data={data} columns={columns} ref={apiRef} />
</>
);
};
Related articles: