Ga naar hoofdinhoud

CnObjectDataWidget

Schema-driven editable data grid widget. Displays object properties in a CSS grid, supports inline editing (click-to-edit with all widget types), dirty tracking, and saves via objectStore.

Usage

<CnObjectDataWidget
title="Character info"
:schema="schema"
:object-data="character"
object-type="characters" />

Props

PropTypeDefaultDescription
titleString'Data'Widget title in the card header
iconObject|FunctionnullOptional MDI icon component for the header
object-dataObjectrequiredThe object to display and edit. Keys must match the schema property keys.
schemaObjectrequiredJSON Schema defining properties. Must have a properties field.
object-typeString''Registered object type slug in the objectStore. Required for saving via objectStore.saveObject().
storeObjectnullOptional objectStore instance. When provided, used directly for saving instead of auto-detecting via Pinia.
overridesObject{}Per-property configuration overrides (see below)
columnsNumber3Number of grid columns
editableBooleantrueWhether inline editing is enabled globally
excludeArray[]Property keys to hide from display
includeArraynullProperty keys to show (whitelist — all others hidden)
save-labelString'Save'Label for the save button
discard-labelString'Discard'Label for the discard button
empty-labelString'No data available'Label when no properties are found

Slots

SlotScoped propsDescription
#actionsExtra buttons in the widget header (right side, next to save/discard)
#field-{key}{ field, value, update, cancel }Override the inline editor for a specific property
#display-{key}{ field, value, raw }Override the display (read-only) view for a specific property

Events

EventPayloadDescription
@savedresult objectEmitted after a successful objectStore save
@save-errorerror messageEmitted when the objectStore save fails
@savemerged data objectEmitted when no objectType is set — lets the parent handle the save
@discardEmitted when the user clicks the discard button

Property overrides

The overrides prop accepts per-property configuration:

{
propertyKey: {
order: 1, // Sort order (lower = first)
gridColumn: 2, // Number of grid columns to span
gridRow: 2, // Number of grid rows to span
hidden: false, // Whether to hide this property
editable: true, // Whether this property can be edited
label: 'Custom', // Override the display label
widget: 'textarea', // Override the widget type for editing
enum: [...], // Override enum values for select/multiselect
}
}

Supported widget types

The widget auto-detects the editor based on the JSON Schema property type:

WidgetSchema typeEditor
textstringText input
emailstring format emailEmail input
urlstring format uriURL input
numbernumber/integerNumber input
textareastring (long)Textarea
selectstring with enumSingle select dropdown
multiselectarray with enumMulti-select dropdown
tagsarray (no enum)Tag input
checkboxbooleanToggle switch
datestring format dateDate picker
datetimestring format date-timeDatetime picker

Example with overrides

<CnObjectDataWidget
title="Publication details"
:schema="publicationSchema"
:object-data="publication"
object-type="publications"
:overrides="{
title: { order: 1, gridColumn: 2 },
description: { order: 2, gridColumn: 2, widget: 'textarea' },
status: { order: 3, editable: false },
internalNotes: { hidden: true },
}" />