Is it possible to hook to the table reorder event, when someone clicks the tick after reordering?

I would like to do a few checks after the tick/check icon is clicked
5 Replies
Dan Harrin
Dan Harrin3y ago
there is no hook atm but you could override reorderTable() on the list page
mwema
mwemaOP3y ago
Let me try this
bionary
bionary2d ago
Still no hook in 2025? It's frustrating because when using Spatie Elequent-Sortable, that package's ::newSortOrder() never gets triggered by Filament so we can't listen for the table sorting event on completion. Feature Request?!? @Dan Harrin So I tried to hook into a model event with ... ->wasChanged('order_column') doesn't work either, so it's impossible to work with table sorting events.
Dan Harrin
Dan Harrin2d ago
Is your intention to come across as demanding?!? No, there is no hook at the moment. You can extend the method on the List/RelationManager class, or submit a PR for something like $table->afterReorder(fn () => ...) to v4
public function reorderTable(array $order, int | string | null $draggedRecordKey = null): void
{
parent::reorderTable($order, $draggedRecordKey);

// do your thing
}
public function reorderTable(array $order, int | string | null $draggedRecordKey = null): void
{
parent::reorderTable($order, $draggedRecordKey);

// do your thing
}
bionary
bionary23h ago
No, my intention was not meant to be in anyway demanding. For anyone looking to fire the Spatie table sorting event like I was, here is some working code: (this is for a relation-manager)
public function reorderTable(array $order, int | string | null $draggedRecordKey = null): void
{
$relation = $this->ownerRecord->{self::$relationship};
if ($relation instanceof \Illuminate\Database\Eloquent\Collection && $relation->isNotEmpty()) {
$class = get_class($relation->first());
}else{
$class = get_class($relation);
}
$class::setNewOrder($order);
}
public function reorderTable(array $order, int | string | null $draggedRecordKey = null): void
{
$relation = $this->ownerRecord->{self::$relationship};
if ($relation instanceof \Illuminate\Database\Eloquent\Collection && $relation->isNotEmpty()) {
$class = get_class($relation->first());
}else{
$class = get_class($relation);
}
$class::setNewOrder($order);
}
I have no idea if this is the best way to do this, but the EloquentModelSortedEvent is fired. I removed parent::reorderTable($order, $draggedRecordKey); because then the update queries are unnecessarily run twice.

Did you find this page helpful?