📄 DataExporter - Exporting items, meta, or both
Use DataExporter when users need to export data from your widget or table.
Quick start
vue
<template>
<DataExporter
:data="exportPayload"
:formats="['json', 'yaml']
filename="servers"
default-format="json"
/>
</template>
<script setup lang="ts">
import DataExporter from "@raclettejs/core/orchestrator/components/dataExport/DataExporter.vue"
const exportPayload = {
items: [
{ id: "1", name: "vm-1" },
{ id: "2", name: "vm-2" },
],
meta: {
generatedAt: new Date().toISOString(),
currency: "EUR",
},
}
</script>Canonical payload shape
DataExporter expects this envelope:
ts
{
items: unknown[]
meta?: unknown
}Data scope switch
The exporter popover provides a data scope switch:
Combined-> exports{ items, meta? }Items-> exports only theitemsarrayMeta-> exports only themetaobject
This is useful when users want:
- just invoice line items (
items) - just configuration object (
meta) - full context (
combined)
Use with BaseDataTable
BaseDataTable already wires DataExporter and emits the export envelope.
vue
<BaseDataTable
:items="rows"
:exportable-items="rows"
item-value="id"
:export-formats="['json', myCustomFormat]"
/>Important
- Always set
item-valueto a real unique key in your row model (id,_id, ...). - If
item-valueis wrong, selected rows can map incorrectly. - Use
export-metawhen your serializers need contextual fields. - Exported row fields are automatically projected to the keys present in
headers. - Columns not present in
headersare not included in exported row objects. - The internal/system
actionscolumn is never exported.
Built-in formats
Built-ins serialize the selected scope payload as-is:
jsonyamlxml
So if users select Items, built-ins serialize just the array.
Troubleshooting
Serializer says payload is invalid
Your custom format likely validates only one shape. Make it support all relevant scope outputs (combined, items, optionally meta) or normalize input before rendering.
Export button disabled
In BaseDataTable, export is disabled when no rows are selected.