Skip to content

Sort Event not Firing #180

Answered by jmorfis
jmorfis asked this question in Q&A
Discussion options

You must be logged in to vote

Well, I figured out that Filament does not call ::setNewSort() and that's why I cannot listen for the event.
In a Filament resource or in my case a Filament relationManager we can override Filament's sorting mechanism. Here's what I came up with:

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

                        $relation = $this->ownerRecord->{self::$relationship};
                        if ($relation instanceof \Illuminate\Database\Eloquent\Collection && $relation->isNotEmpty()) {
                            $class = g…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jmorfis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant