{# def id, data, columns=[], buttons=[], empty_message=None, icon="bi-hdd-stack", label="Title", rowgroup=None, responsive={'details':{'renderer':'tableHidden'}}, description=None, enabled=True #}
{% set html_title %}
  <Icon value={{ icon }} /> {{ label }}
{% endset %}
{# Prepare the button configurations #}
{% set title = label|striptags %}
{% set filename = title + '_' + (now() | format_datetime("yyyy-MM-dd_HH-mm-ss")) %}
{% set copy_button = {'text': _('Copy'), 'extend': 'copy', 'className':'btn-outline-secondary', 'copySuccess': false, 'exportOptions': {'columns': '.export'}, 'title': '# ' + title } %}
{% set csv_button = {'text': _('Download CSV'), 'extend': 'csv', 'exportOptions': {'columns': '.export'}, 'filename': filename, 'title': title } %}
{% set xsl_button = {'text': _('Download XLSX'), 'extend': 'excel', 'exportOptions': {'columns': '.export'}, 'filename': filename, 'title': title } %}
{% set export_button = {'text': _('Export') + ' ', 'extend': 'collection', 'align':'button-right', 'autoClose':True, 'background': False, 'popoverTitle': _('Export'), 'buttons': [ csv_button, xsl_button], 'className':'btn-outline-secondary' } %}
{% set all_buttons = buttons + [export_button, copy_button] %}
{# Define a custom layout to mimic a card. #}
{% set layout = {
  'topStart': {
    'rowClass': 'dt-layout-row card-header',
    'features': {'div': {'html': html_title, 'className': 'col h5 mb-0'} }
  },
  'topEnd': {
    'className': 'dt-layout-cell dt-layout-end d-print-none',
    'features': 'buttons'
  },
  'bottomStart': None,
} %}
<div class="card shadow{{ ' ssp-datatable-disabled' if not enabled else ''}}">
  <Datatable id={{ id }} data={{ data }} columns={{ columns }} buttons={{ all_buttons }} layout={{ layout }} empty_message={{ empty_message }}  paging={{ False }} rowgroup={{ rowgroup }} scroll_y="22em" responsive={{ responsive }} />
</div>
