F
Filament2mo ago
Sydd

TablesRenderHook after table filter / toggle columns

Dear friends, in list page I'm provide renderhook to table toolbar ... everything works OK, but when on the table are used filters or toogle columns ... this render hook / livewire component is not rendered again (only after hard page refresh) Have somebody similar progblem and find solution ?
public function mount(): void
{
$name = substr(strrchr(static::getName(), '.'), 1);
FilamentView::registerRenderHook(
TablesRenderHook::TOOLBAR_START,
fn (): string => Blade::render(
"@livewire('filament.toggle-chart-icon-button',
[
'tableName' => '$name',
]
)"
)
);
}
public function mount(): void
{
$name = substr(strrchr(static::getName(), '.'), 1);
FilamentView::registerRenderHook(
TablesRenderHook::TOOLBAR_START,
fn (): string => Blade::render(
"@livewire('filament.toggle-chart-icon-button',
[
'tableName' => '$name',
]
)"
)
);
}
2 Replies
dvarilek
dvarilek2mo ago
This might be because your livewire component doesn't seem to have a wire:key set. You could try something like this
@livewire('filament.toggle-chart-icon-button', [
'tableName' => $name,
], key("toggle-chart-{$name}"))
@livewire('filament.toggle-chart-icon-button', [
'tableName' => $name,
], key("toggle-chart-{$name}"))
Sydd
SyddOP2mo ago
Thanks, Dvarilek! I’ll try your answer. Now I’m diving deeper into the Filament docs to find the absolute best solution, register it in the panel provider, and use scopes for the required pages. And what really surprised me was being able to send the current scope to a Livewire component. Oh… Filament never stops surprising me—it's truly amazing.
->renderHook(
TablesRenderHook::TOOLBAR_TOGGLE_COLUMN_TRIGGER_AFTER,
function (array $scopes): string {
return Livewire::mount(
'filament.toggle-chart-icon-button',
['scopes' => $scopes]
);
},
scopes: [
ListAmbulances::class,
ListCashes::class,
]
);
->renderHook(
TablesRenderHook::TOOLBAR_TOGGLE_COLUMN_TRIGGER_AFTER,
function (array $scopes): string {
return Livewire::mount(
'filament.toggle-chart-icon-button',
['scopes' => $scopes]
);
},
scopes: [
ListAmbulances::class,
ListCashes::class,
]
);

Did you find this page helpful?