gp-grid-logo
Examples

Editing

Enable inline cell editing and the fill handle in the Vue 3 grid with validators, custom editors, keyboard shortcuts, and clipboard-style range fill flows.

gp-grid supports inline cell editing with Excel-like fill handle.

Interactive Demo

Enable Editing

Set editable: true on column definitions:

<script setup lang="ts">
const columns: ColumnDefinition[] = [
  { field: "id", cellDataType: "number", width: 80 },
  {
    field: "name",
    cellDataType: "text",
    width: 150,
    editable: true,
  },
];
</script>

Start Editing

ActionDescription
Double-clickOpen editor with current value
EnterOpen editor with current value
F2Open editor with current value
Start typingOpen editor with typed character

Commit or Cancel

ActionDescription
EnterCommit changes and move down
TabCommit changes and move right
EscapeCancel changes
Click outsideCommit changes

Fill Handle

The fill handle appears at the bottom-right corner of selected cells. Drag it to fill values.

Custom Edit Renderers

<script setup lang="ts">
import { Grid, type EditRendererParams } from "@gp-grid/vue";
import { h } from "vue";

const DepartmentEditor = (params: EditRendererParams) => {
  return h("select", {
    value: params.value,
    autofocus: true,
    onChange: (e: Event) => {
      params.onValueChange((e.target as HTMLSelectElement).value);
      params.onCommit();
    },
    onKeydown: (e: KeyboardEvent) => {
      if (e.key === "Escape") params.onCancel();
    },
  }, [
    h("option", { value: "Engineering" }, "Engineering"),
    h("option", { value: "Marketing" }, "Marketing"),
    h("option", { value: "Sales" }, "Sales"),
  ]);
};
</script>

<template>
  <Grid
    :columns="columns"
    :row-data="data"
    :row-height="36"
    :edit-renderers="{ department: DepartmentEditor }"
  />
</template>