F
Filamentβ€’16mo ago
sejtam

Refresh table after changing values with updateStateUsing

Hello, I using CheckBoxColumn to select default language. I changing values of rows in updateStateUsing and I need render this values after change. (Only after the page is refreshed will it be rendered). Is there a way to do this? Thank you for your answers πŸ™‚
CheckboxColumn::make(config('better-lang.tables.columns.lang_code.default'))
->label(__('filament-better-lang::resources.lang_code.columns.default'))
->updateStateUsing(function ($record, $state) {
if($state) {
static::getModel()::query()
->update(['default' => false]);
$record->update(['default' => true]);
}

// TODO: Refresh table
return $state;
})
CheckboxColumn::make(config('better-lang.tables.columns.lang_code.default'))
->label(__('filament-better-lang::resources.lang_code.columns.default'))
->updateStateUsing(function ($record, $state) {
if($state) {
static::getModel()::query()
->update(['default' => false]);
$record->update(['default' => true]);
}

// TODO: Refresh table
return $state;
})
1 Reply
Gustave
Gustaveβ€’15mo ago
Hi, I've had the same issue. did you find a solution for you ? my issue came from getStateUsing where I used eager loaded value instead of a fresh one. If it can help
Want results from more Discord servers?
Add your server