Swapping two values in list record

Does anyone have any idea how to swap the two values within a list record? Filament provides a reordering feature, but it affects the entire column. I only want to modify the positions of the swapped values, not the entire column.
4 Replies
Dennis Koch
Dennis Koch2y ago
Maybe write a Table Action that can move up/down and use it as an Action on that column.
ZedoX
ZedoX2y ago
If I understand what you are trying to do (multiple entries in the same position), I wouldn't use the "sort" feature. I would just have a field that can be updated by the user. If you don't like this you can try Dennis's suggestion above ^
ba_mbi_07
ba_mbi_07OP2y ago
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
Tables\Actions\Action::make('swap')->label('Swap')
->action(function(){

})
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
Tables\Actions\Action::make('swap')->label('Swap')
->action(function(){

})
])
I did add action but i can not able to understand how to "that can move up/down" i thought reorder will work in my case i just wanted use reorder in between same page_slug not entire column
->reorderable('position', function (Column $column) {
$column->where('page_slug', function ($query, $value) {
// dd($value);
return $query->where('page_slug', $value);
});
});
->reorderable('position', function (Column $column) {
$column->where('page_slug', function ($query, $value) {
// dd($value);
return $query->where('page_slug', $value);
});
});
Dennis Koch
Dennis Koch2y ago
You might hack the reorder feature for this. I think there are some reorder methods on the ListRecords page that could be overwritten.
Want results from more Discord servers?
Add your server