rappasoft / laravel-livewire-tables

A dynamic table component for Laravel Livewire
https://rappasoft.com/docs/laravel-livewire-tables/v2/introduction
MIT License
1.74k stars 329 forks source link

Pagination questions #268

Closed developman-akl closed 3 years ago

developman-akl commented 3 years ago

Using 1.5.1 with Tailwind seems like these properties have no effect:

public bool $showPagination = false;
public int $perPage = 6;

Overwriting $perPage in the WithPerPagePagination trait works, should work via overwriting the property too:

public function mountWithPerPagePagination(): void
{
    ...
    } else {
        $this->perPage = 6;
    }
}

$showPagination is an unused property. What would be the purpose of it?

With TW it shows duplicated pagination, would be good to be able to switch off each of them, maybe via $showPagination ? image

Thank you.

rappasoft commented 3 years ago

showPagination is definitely unused, I don't remember if we took it out of the templates for some reason. But perPage seems to be working fine for me:

public array $perPageAccepted = [1,2,4];
public int $perPage = 2;
Screen Shot 2021-05-03 at 09 00 25

You probably shouldn't override the mount methods.

rappasoft commented 3 years ago

Added missing showPagination conditional to views: https://github.com/rappasoft/laravel-livewire-tables/commit/c99e8351d4f69fcaa566e7d39734a85bc52c2cfb

Either way, I don't know why you're seeing two types of pagination. Do you have Laravels default pagination views published and modified?

developman-akl commented 3 years ago

No, I haven't published the default pagination views, also the mount method is not overridden.

developman-akl commented 3 years ago

Update: Now as I published the livewire paginations, the duplication is gone.

The $perPage issue has something to do with the trait's session if clause. Commenting out the else clause makes it work. image

developman-akl commented 3 years ago

Update:

With the livewire paginations published having these two properties overwritten, the custom $perPage works without modifying the trait:

    public int $perPage = 6;
    public array $perPageAccepted = [6];