coryrose1 / livewire-tables

An extension for Laravel Livewire that allows you to effortlessly scaffold datatables with optional pagination, search, and sort.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue/Conflict with Livewire\HasPagination trait

coryrose1 opened this issue · comments

Something in the table component is overriding the WithPagination trait provided by Livewire.

The pagination view being loaded is actually the default Laravel / Bootstrap view. This results in full-page reloads / going to ?page=[number] in the URL. It also ceases to work after any Livewire method is run (i.e. sort or search then try pagination and it will result in an error).

There is an initializeWithPagination() method in the trait that does the following:

public function initializeWithPagination()
    {
        Paginator::currentPageResolver(function () {
            return $this->paginator['page'];
        });

        Paginator::defaultView('livewire::pagination-links');
    }

Pagination::defaultView() is not taking effect unless placed directly into AppServiceProvider.

However even when set, the Livewire pagination is not functioning correctly.

Can anyone identify why the pagination trait should be affected, by either LivewireModelTable component or the user-generated table component? If anyone can help me dig into this, I'd appreciate it.

This issue is now resolved. LivewireModelTable had to construct the parent Livewire component for pagination to function.