Export Dialog
Style-agnostic export dialog component.
Preview
Export Data
Format
Columns
python
export_dialog(open=True, formats=['csv', 'xlsx', 'json'], columns=[{'id': 'name', 'label': 'Name'}, {'id': 'email', 'label': 'Email'}, {'id': 'joined', 'label': 'Joined', 'checked': False}])The dialog requires a host action and export payload, so it has no standalone preview.
Usage
views.py
python
from djust import LiveView
from djust.decorators import event_handler
from djust.components import ExportDialog
class MyView(LiveView):
template_name = "my_template.html"
def mount(self, request, **kwargs):
self.component = ExportDialog(open=True, formats=['csv', 'xlsx', 'json'], columns=[{'id': 'name', 'label': 'Name'}, {'id': 'email', 'label': 'Email'}, {'id': 'joined', 'label': 'Joined', 'checked': False}])
@event_handler()
def close_export(self, **kwargs):
self.component.open = False
@event_handler()
def export(self, **kwargs):
pass # your app acts on 'export'; no component state movesmy_template.html
django
{{ component }}Events this component sends to the view: close_export, export.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| formats | list | None | None | List of available export formats |
| columns | list | None | None | List of column dicts with id, label, checked |
| event | str — renames the event; identity is `name` | 'export' | djust event for triggering export |
| open | bool | False | Whether the dialog is visible |
| close_event | str — renames the event; identity is `name` | 'close_export' | djust event for closing |
| selected_format | str | '' | Currently selected format |
| title | str | 'Export Data' | Dialog title |
| custom_class | str | '' | Additional CSS classes |
| **kwargs | — passed to `Component.__init__`: `name=` identifies the instance in the events it sends, `id=` sets `component.id`, and any other keyword is kept as state | — | — |
Source & styles
| File | Path | Notes |
|---|---|---|
| module | djust.components.components.export_dialog | Subclass it, or pass custom_class, to change how it renders. |
| css | djust_components/components.css | Defines 14 of this component's classes at line 1912, 1913, 1914, 1916, 1917, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 2744. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |
| css | djust_theming/catalogue.css | Defines 2 of this component's classes at line 158, 162. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |
| css | djust_theming/components.css | Defines 1 of this component's classes at line 1612. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |