Refresh a table

I have a radio in my table, and when i click it, my code runs, but i need to refresh the table. Can anyone help?
Tables\Columns\ViewColumn::make('root step')->action(function (ItemProcessStep $step) {
$this->ownerRecord->root_step_id = $step->id;
$this->ownerRecord->save();
$this->reset(); // this does't work, what should I actually be doing?
})->view('tables.columns.root-step-radio', ['rootStep' => $rootStep]),
Tables\Columns\ViewColumn::make('root step')->action(function (ItemProcessStep $step) {
$this->ownerRecord->root_step_id = $step->id;
$this->ownerRecord->save();
$this->reset(); // this does't work, what should I actually be doing?
})->view('tables.columns.root-step-radio', ['rootStep' => $rootStep]),
No description
9 Replies
delboy1978uk
delboy1978ukOPβ€’2w ago
I tried resetTable() as well but it didn't work either, nothing happens code now looks like this
->columns([
Tables\Columns\ViewColumn::make('root step')
->state(function (ItemProcessStep $step) use ($rootStep): string {
return $rootStep === $step->id ? 'checked ' : '';
})
->action(function (ItemProcessStep $step) {
$this->ownerRecord->root_step_id = $step->id;
$this->ownerRecord->save();
$this->resetTable();
})
->view('tables.columns.root-step-radio', ['rootStep' => $rootStep]),
->columns([
Tables\Columns\ViewColumn::make('root step')
->state(function (ItemProcessStep $step) use ($rootStep): string {
return $rootStep === $step->id ? 'checked ' : '';
})
->action(function (ItemProcessStep $step) {
$this->ownerRecord->root_step_id = $step->id;
$this->ownerRecord->save();
$this->resetTable();
})
->view('tables.columns.root-step-radio', ['rootStep' => $rootStep]),
toeknee
toekneeβ€’2w ago
So this is because you are using a ViewColumn, you will want an inputColumn. The reason it doesn't work is as the data is refresh viewcolumns are not re-populated. Same with Forms.
delboy1978uk
delboy1978ukOPβ€’7d ago
@toeknee thanks so much! πŸ™β€οΈ are you also able to advise on a header action button being refreshed too? next to my delete button on my edit page i have a custom button, that once pressed, should instead display a cancel button, currently i need to refresh the page to see that too
protected function getHeaderActions(): array
{
// $release = Action::make ..
// $cancel = Action::make ..
// 4delete = DeleteAction::make ..

return $releaseService->isReleased($this->record) ? [$cancel, $delete] : [$release, $delete];
}
protected function getHeaderActions(): array
{
// $release = Action::make ..
// $cancel = Action::make ..
// 4delete = DeleteAction::make ..

return $releaseService->isReleased($this->record) ? [$cancel, $delete] : [$release, $delete];
}
toeknee
toekneeβ€’7d ago
buttons are out of the scope. You could try a page reload on refresh or add a listener to reprocess them?
delboy1978uk
delboy1978ukOPβ€’7d ago
a listener sounds like the best way to go i think, i'll look that up. Thank you once again! The listener works great, thank you so much @toeknee !
toeknee
toekneeβ€’7d ago
Maybe provide your solution for others.
delboy1978uk
delboy1978ukOPβ€’6d ago
It did, thank you once again @toeknee πŸ™
Mugwe
Mugweβ€’6d ago
I think toeknee meant you share how you implemented the listener in your code so one who has a similar problem will know how to go about it.

Did you find this page helpful?