Skip to main content

update-row

Description

Fires when updating a row

Usage

"update-row": ({
id: string | number,
row: Record<string, any>,
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 updated
  • row - (required) the new row data
  • eventSource - (optional) the name of the Grid action that triggered update-row

Returning false from the event handler will block updating data in rows.

Example

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

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

const apiRef = useRef(null);

const updateRow = () => {
apiRef.current.exec("update-row", {
id: 11,
row: { city: "New City", firstName: "New name", lastName: "new name" },
});
};

return (
<>
<Button onClick={updateRow} type="primary">Update Row</Button>
<Grid data={data} columns={columns} ref={apiRef} />
</>
);
}

Related articles: