This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Briddle
Briddle

In the hope of helping others I am adding this problem and it's solution.

To update elements in backend scoreboards or charts used above lists in your backend controller views when filters are applied add the following to your controller:

private $extendFilterOnce = false;

    /**
     * @param Filter $filter
     * @return void
     */
    public function listFilterExtendScopes($filter)
    {

        if ($this->extendFilterOnce) {
            return;
        }

        $this->extendFilterOnce = true;

        $filter->onFilterUpdate();

        $query = YourModel::query();

        foreach ($filter->getScopes() as $scope) {
            /** @noinspection PhpParamsInspection */
            $filter->applyScopeToQuery($scope, $query);
        }

        $filter->bindEvent('filter.update', function () use ($query): array {
            return [
                '#scoreboard-total' => $query->count(),
            ];
        });
    }

Source: https://github.com/octobercms/october/issues/2912

Briddle
Briddle

Hmmm, found my own post when searching for this solution. Thank you younger me!

Last updated

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.