Skip to content

Fix datatable dom property #5812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/resources/assets/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -812,18 +812,14 @@ div.dt-scroll-body {
margin-bottom: 0;
}

.dt-buttons {
margin-bottom: 8px;
}

/* Adjust table headers */
.dataTable thead th {
font-size: 0.70em;
font-weight: 700;
}

/* Make export and column visibility buttons smaller */
.dataTables_wrapper .dt-buttons .btn {
.dt-container .dt-buttons .btn-group .btn {
padding: 0.25rem 0.5rem;
font-size: 0.875rem;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,23 @@ functionsToRunOnDataTablesDrawEvent: [],
"colvis": "{{ trans('backpack::crud.export.column_visibility') }}"
},
},
dom:
"<'row hidden'<'col-sm-6'i><'col-sm-6 d-print-none'f>>" +
"<'table-content row'<'col-sm-12'tr>>" +
"<'table-footer row mt-2 d-print-none align-items-center '<'col-sm-12 col-md-4'l><'col-sm-0 col-md-4 text-center'B><'col-sm-12 col-md-4 'p>>",
layout: {
topStart: null,
topEnd: null,
bottomEnd: null,
bottomStart: null,
bottom: [
'pageLength',
{
buttons: config.exportButtons ? window.crud.exportButtonsConfig : []
},
{
paging: {
firstLast: false,
}
}
]
},
buttons: []
};

Expand Down Expand Up @@ -406,7 +419,7 @@ functionsToRunOnDataTablesDrawEvent: [],

// Configure export buttons if present
if (config.exportButtons) {
dataTableConfig.buttons = window.crud.exportButtonsConfig;
dataTableConfig.layout.bottom.buttons = window.crud.exportButtonsConfig;
}


Expand Down Expand Up @@ -526,8 +539,6 @@ function setupTableUI(tableId, config) {
}
});
window.dispatchEvent(event);
// move the bottom buttons before pagination
$(`#bottom_buttons_${tableId}`).insertBefore($(`#${tableId}_wrapper .row:last-child`));
}

// Function to set up table event handlers
Expand Down
8 changes: 4 additions & 4 deletions src/resources/views/crud/inc/export_buttons.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
{
extend: 'collection',
text: '<i class="la la-download"></i> {{ trans('backpack::crud.export.export') }}',
className: 'buttons-collection dropdown-toggle',
dropup: true,
buttons: [
{
Expand Down Expand Up @@ -134,6 +135,7 @@
,{
extend: 'colvis',
text: '<i class="la la-eye-slash"></i> {{ trans('backpack::crud.export.column_visibility') }}',
className: 'buttons-collection dropdown-toggle',
columns: function ( idx, data, node ) {
return $(node).attr('data-can-be-visible-in-table') == 'true';
},
Expand All @@ -148,14 +150,12 @@
var table = window.crud.tables[tableId];

if (!table || !table.buttons) return;

table.buttons().each(function(button) {
if (button.node.className.indexOf('buttons-columnVisibility') == -1 && button.node.nodeName=='BUTTON') {
button.node.className = button.node.className + " btn-sm";
button.node.className = button.node.className.replace('btn-secondary', 'btn-sm');
}
});

$(`#${tableId}_wrapper .dt-buttons`).appendTo($('.datatable_button_stack'));

$('.dt-buttons').addClass('d-xs-block')
.addClass('d-sm-inline-block')
.addClass('d-md-inline-block')
Expand Down