Skip to content

Commit

Permalink
Merge pull request #5745 from Laravel-Backpack/fix-colspan-issue-
Browse files Browse the repository at this point in the history
fix page lenght stalling in cache & colspan issue on the table
  • Loading branch information
pxpm authored Jan 8, 2025
2 parents 5a39ace + 9d1c5a6 commit c0d1493
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/app/Http/Controllers/Operations/ListOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public function search()
$filteredEntryCount = $this->crud->getFilteredQueryCount() ?? $totalEntryCount;
} else {
$totalEntryCount = $length;
$filteredEntryCount = $entries->count() < $length ? 0 : $length + $start + 1;
$entryCount = $entries->count();
$filteredEntryCount = $entryCount < $length ? $entryCount : $length + $start + 1;
}

// store the totalEntryCount in CrudPanel so that multiple blade files can access it
Expand Down
11 changes: 9 additions & 2 deletions src/resources/views/crud/inc/datatables_logic.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,19 @@
let $dtCachedInfo = JSON.parse(localStorage.getItem('DataTables_crudTable_/{{$crud->getRoute()}}'))
? JSON.parse(localStorage.getItem('DataTables_crudTable_/{{$crud->getRoute()}}')) : [];
var $dtDefaultPageLength = {{ $crud->getDefaultPageLength() }};
let $dtStoredPageLength = localStorage.getItem('DataTables_crudTable_/{{$crud->getRoute()}}_pageLength');
let $pageLength = @json($crud->getPageLengthMenu());
let $dtStoredPageLength = parseInt(localStorage.getItem('DataTables_crudTable_/{{$crud->getRoute()}}_pageLength'));
if(!$dtStoredPageLength && $dtCachedInfo.length !== 0 && $dtCachedInfo.length !== $dtDefaultPageLength) {
localStorage.removeItem('DataTables_crudTable_/{{$crud->getRoute()}}');
}
if($dtCachedInfo.length !== 0 && $pageLength.indexOf($dtCachedInfo.length) === -1) {
localStorage.removeItem('DataTables_crudTable_/{{$crud->getRoute()}}');
}
// in this page we always pass the alerts to localStorage because we can be redirected with
// persistent table, and this way we guarantee non-duplicate alerts.
$oldAlerts = JSON.parse(localStorage.getItem('backpack_alerts'))
Expand Down Expand Up @@ -226,7 +233,7 @@ functionsToRunOnDataTablesDrawEvent: [],
@endif
autoWidth: false,
pageLength: $dtDefaultPageLength,
lengthMenu: @json($crud->getPageLengthMenu()),
lengthMenu: $pageLength,
/* Disable initial sort */
aaSorting: [],
language: {
Expand Down

0 comments on commit c0d1493

Please sign in to comment.