F
Filament11mo ago
faroukb

How to toggle pagination ?

Hey everyone, is there anyway to add an action that toggles pagination ? thanks
16 Replies
Dennis Koch
Dennis Koch11mo ago
What do you mean? Toggle it on/off?
faroukb
faroukb11mo ago
Yes exactly A button that can enable/disable pagination within a table
Dennis Koch
Dennis Koch11mo ago
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
faroukb
faroukb11mo ago
I am not sure that works, here is my code : Within the list records
faroukb
faroukb11mo ago
No description
faroukb
faroukb11mo ago
and within the resource
faroukb
faroukb11mo ago
No description
Dennis Koch
Dennis Koch11mo ago
Might need a refresh of the table afterwards
faroukb
faroukb11mo ago
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 ?
Dennis Koch
Dennis Koch11mo ago
You need to emit an Event and use a LW Listener to run $refresh. Haven't touched LW3 yet.
josef
josef11mo ago
use $this->dispatch('refreshTable'); in the action, and add protected $listeners = ['refreshTable' => '$refresh'] in the livewire component / page
faroukb
faroukb11mo ago
In my case I am trying to refresh a class extending ListRecords but it still not working
faroukb
faroukb11mo ago
No description
Dennis Koch
Dennis Koch11mo ago
Hm I don’t know. Is the table rerendered? Is getIsPaginated() called?
faroukb
faroukb11mo ago
Yes here is my code
faroukb
faroukb11mo ago
Within the public static function table(Table $table): Table
No description