Okipa / laravel-table

Generate tables from Eloquent models.
MIT License
533 stars 64 forks source link

Search by does not refresh the page number #141

Open chtidom opened 1 year ago

chtidom commented 1 year ago

When you display a list and you use the search field above the table the selection is just done on the page displayed while it should do the search on the whole table Needs to add the following method in the class vendor/okipa/laravel-table/src/Livewire/Table.php public function updating($name, $value){ if ($name === "searchBy"){ $this->resetPage(); } }

jaymeh commented 5 months ago

I think this sounds very similar to an issue I am faced with at the moment. When you browse through the table results and you go to "page 17" for instance then do a filter, you get a page like what I have attached. Clicking on page 1 at the bottom shows results but it isn't a nice user experience.

I tried the code mentioned by @chtidom above and that seems to resolve the issue for me although I'm not sure what kind of side effects this could cause.

CleanShot 2024-04-22 at 15 07 33

HawtDogFlvrWtr commented 4 months ago

Agreed. I'm seeing the same thing and was just about to post about it :D

HawtDogFlvrWtr commented 4 months ago

This also happens if you select a page number and then change the number of rows to display to something higher than the page number would display. To fix this you need to update the same file with this

    public function changeNumberOfRowsPerPage(int $numberOfRowsPerPage): void
    {
        $this->numberOfRowsPerPage = $numberOfRowsPerPage;
        $this->resetPage();
    }