Skip to content

Commit aeea538

Browse files
authored
Merge pull request #5833 from Laravel-Backpack/fix-datatables-when-no-export-buttons-set
fix table without export buttons
2 parents 028acc7 + e6b795a commit aeea538

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

src/resources/assets/css/common.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ div[id$="_wrapper"] .dt-processing {
9797
top: 0 !important;
9898
left: 0 !important;
9999
right: 0 !important;
100-
bottom: 60px !important;
100+
bottom: 40px !important;
101101
width: 100% !important;
102-
height: calc(100% - 60px) !important;
102+
height: calc(100% - 40px) !important;
103103
transform: none !important;
104104
margin: 0 !important;
105105
z-index: 1000 !important;

src/resources/views/crud/components/datatable/datatable_logic.blade.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,19 +310,25 @@ functionsToRunOnDataTablesDrawEvent: [],
310310
topEnd: null,
311311
bottomEnd: null,
312312
bottomStart: null,
313-
bottom: [
313+
bottom: config.exportButtons ? [
314314
'pageLength',
315315
{
316-
buttons: config.exportButtons ? window.crud.exportButtonsConfig : []
316+
buttons: window.crud.exportButtonsConfig
317317
},
318318
{
319319
paging: {
320320
firstLast: false,
321321
}
322322
}
323+
] : [
324+
'pageLength',
325+
{
326+
paging: {
327+
firstLast: false,
328+
}
329+
}
323330
]
324-
},
325-
buttons: []
331+
}
326332
};
327333
328334
// Add responsive details if needed
@@ -552,6 +558,14 @@ function setupTableUI(tableId, config) {
552558
new $.fn.dataTable.Buttons(window.crud.tables[tableId], {
553559
buttons: window.crud.exportButtonsConfig
554560
});
561+
562+
if (typeof window.crud.moveExportButtonsToTopRight === 'function') {
563+
config.addFunctionToDataTablesDrawEventQueue('moveExportButtonsToTopRight');
564+
}
565+
if (typeof window.crud.setupExportHandlers === 'function') {
566+
config.addFunctionToDataTablesDrawEventQueue('setupExportHandlers');
567+
}
568+
555569
// Initialize the buttons and place them in the correct container
556570
if (typeof window.crud.moveExportButtonsToTopRight === 'function') {
557571
window.crud.moveExportButtonsToTopRight(tableId);

src/resources/views/crud/inc/export_buttons.blade.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,6 @@ className: 'buttons-collection dropdown-toggle',
186186
.addClass('d-md-inline-block')
187187
.addClass('d-lg-inline-block');
188188
};
189-
190-
// Add the function to the draw event queue
191-
window.crud.defaultTableConfig.addFunctionToDataTablesDrawEventQueue('moveExportButtonsToTopRight');
192189
193190
window.crud.setupExportHandlers = function(tableId) {
194191
tableId = tableId || 'crudTable';
@@ -229,9 +226,6 @@ className: 'buttons-collection dropdown-toggle',
229226
}
230227
});
231228
};
232-
233-
// Add the export handler setup to the draw event queue
234-
window.crud.defaultTableConfig.addFunctionToDataTablesDrawEventQueue('setupExportHandlers');
235229
</script>
236230
@push('after_styles')
237231
@basset('https://cdn.datatables.net/buttons/3.2.0/css/buttons.bootstrap5.min.css')

0 commit comments

Comments
 (0)