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 - (required) the ID of a column for which the editor is open

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,
},
];

let api;

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

<Grid {data} {columns} bind:api />

Related articles: