F
Filamentβ€’2y ago
Antoine

Reset in columns toggleable?

I see that the ability to make a table's toggle clear has not been deployed? Do you know a method to reset columns toggleable to their default values? thx
10 Replies
Antoine
AntoineOPβ€’2y ago
or a method to go back to default table?
Patrick Boivin
Patrick Boivinβ€’2y ago
Not sure but I think the visible columns are stored in the browser local storage... maybe you can add a button in your page to clear it
Antoine
AntoineOPβ€’2y ago
Ok, I see. But how can I get default values of these columns to inject in a new session? Thank's the response πŸ™‚
Patrick Boivin
Patrick Boivinβ€’2y ago
Right, so it's stored in the PHP session, not local storage. Just did a quick test, this will reset to the default columns on a ListPosts page:
session()->remove('tables.ListPosts_toggled_columns');
session()->remove('tables.ListPosts_toggled_columns');
Antoine
AntoineOPβ€’2y ago
Many thanks @pboivin and for anyone looking to reset all table action sessions through a button for example: session()->remove('tables'); Do you know if it is possible to display a button at the end of table lookup or other table actions like for a Filament::registerRenderHook() ?
Patrick Boivin
Patrick Boivinβ€’2y ago
I'm not sure... where exactly do you want to add the button?
Antoine
AntoineOPβ€’2y ago
I want to add a button at the end of the toggle button or filters. I searched in the documentation but Filament doesn't have renderHooks in the toolbar header table. So I created lots of simple render hooks that work like a charm in the toolbar header table. This would make Filament even more flexible but I don't know if @Dan Harrin is interested by this option. If he is interested, I propose me to make a pull request and add the renderHooks to the documentation? It's only renderHooks like this : {{ \Filament\Support\Facades\FilamentView::renderHook('panels::resource.pages.list-records.table.filters.end', scopes: $this->getRenderHookScopes()) }}
Antoine
AntoineOPβ€’2y ago
and more...
Patrick Boivin
Patrick Boivinβ€’2y ago
Looks good to me, I would say take a chance and send a PR πŸ˜„
BlackShadow
BlackShadowβ€’14mo ago
This would be a really nice addition to core πŸ™‚ (Just like filters adding a Reset button)

Did you find this page helpful?