How to toggle pagination ?
Hey everyone, is there anyway to add an action that toggles pagination ? thanks
16 Replies
What do you mean? Toggle it on/off?
Yes exactly
A button that can enable/disable pagination within a table
You could probably save it in a property on the Livewire component and then query that property in the method that controls pagination. Not 100% sure of all the steps though
I am not sure that works, here is my code :
Within the list records
![No description](https://answer-overflow-discord-attachments.s3.amazonaws.com/1146050632097218631/Screen_Shot_2023-08-29_at_07.55.39_AM.png)
and within the resource
![No description](https://answer-overflow-discord-attachments.s3.amazonaws.com/1146050834463997962/Screen_Shot_2023-08-29_at_07.56.29_AM.png)
Might need a refresh of the table afterwards
How can you do that within the action function ? is there a specific function that we can call from the
$this->getTable()
or another way arround ?You need to emit an Event and use a LW Listener to run
$refresh
. Haven't touched LW3 yet.use
$this->dispatch('refreshTable');
in the action, and add protected $listeners = ['refreshTable' => '$refresh']
in the livewire component / pageIn my case I am trying to refresh a class extending
ListRecords
but it still not working![No description](https://answer-overflow-discord-attachments.s3.amazonaws.com/1146180451065663609/Screen_Shot_2023-08-29_at_16.31.39_PM.png)
Hm I don’t know. Is the table rerendered? Is
getIsPaginated()
called?Yes here is my code
Within the
public static function table(Table $table): Table
![No description](https://answer-overflow-discord-attachments.s3.amazonaws.com/1146404011830952027/Screen_Shot_2023-08-30_at_07.19.11_AM.png)