Skip to main content

open-editor

Description

Fires when opening the inline editor

Usage

"open-editor": ({
id: string,
column?: string,
}) => boolean|void;

Parameters

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

  • id - (required) the ID of a cell that is updated
  • column - (optional) the ID of a column for which the editor is open (if not specified, the closest column with editor in a cell will be opened)

Returning false from the event handler will block editor opening.

Example

<script>
import { Grid } from "wx-svelte-grid";
import { getData } from "./common/data";
const { data, countries, users } = getData();

const columns = [
{ id: "id", width: 50 },
{ id: "firstName", header: "Name", editor: "text", width: 160 },
{
id: "country",
header: "Country",
editor: "combo",
options: countries,
width: 160,
},
{
id: "checked",
hidden: true,
header: "Active",
editor: "combo",
width: 160,
},
{
id: "newsletter",
header: "Newsletter",
editor: "combo",
width: 100,
},
{
id: "date",
header: "Date",
width: 100,
editor: "datepicker",
},
{
id: "assigned",
header: "Users",
width: 100,
editor: "combo",
options: users,
},
{
id: "companyName",
header: "Comments",
editor: "text",
flexgrow: 1,
},
];

function init(api){
api.on("open-editor", (ev) => {
console.log("The column id for which the editor is open:", ev.column);
});
}
</script>

<Grid {data} {columns}
{init} />

Related articles: