Skip to content

📄 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 the items array
  • Meta -> exports only the meta object

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-value to a real unique key in your row model (id, _id, ...).
  • If item-value is wrong, selected rows can map incorrectly.
  • Use export-meta when your serializers need contextual fields.
  • Exported row fields are automatically projected to the keys present in headers.
  • Columns not present in headers are not included in exported row objects.
  • The internal/system actions column is never exported.

Built-in formats

Built-ins serialize the selected scope payload as-is:

  • json
  • yaml
  • xml

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.