oliverbj
oliverbj

Reputation: 6062

Filament Table Text Column action not firing

I have a Filament table widget, in which I do a semi complex query to fetch some grouped data:

public function table(Table $table): Table
{
    return $table
        ->query(
            $this->sql()
        )
        ->striped()
        ->heading('Missing Co-Loader')
        ->columns([
            TextColumn::make('job_operator_name')->label('Job Operator Name'),
            TextColumn::make('num_jobs')->label('Total Jobs')->alignCenter()->action(
                ViewAction::make('test')
                ->modalContent(fn (Model $model): View => view(
                    'filament.app.widgets.pegasus.commercial.top-stats-widget',
                    [
                        'model' => $model,
                    ],
                    ))
                )
            ]);
}

protected function sql()
{
    return ReportShipment::query()
                ->select(
                    DB::raw('ROW_NUMBER() OVER (ORDER BY COUNT(id) DESC) as id'),
                    'job_operator_name',
                    DB::raw('COUNT(id) as num_jobs')
                )
                ->where('consol_type', 'CLD')
                ->whereNull('consol_co_loaded_with_code')
                ->groupBy('job_operator_name')
                ->orderByDesc('num_jobs');

}

public function getTableRecordKey($record): string   
{
    $name = str_replace(' ', '_', $record->job_operator_name);
    return 'missing_co_loader_widget_'.$name;
}

This will yield a table like this:

|Job Operator Name| Total Jobs |
--------------------------------
|Name A           |      5     |
|Name B           |     15     |   
...

And the number in the Total Jobs column will be clickable.

However, when I click the number, nothing happens. If I check the console -> network requests, I see that an update request is indeed sent, but still - nothing happens. I would expect the action to open a modal, with the content from my custom blade view.

What am I doing wrong?

Upvotes: 0

Views: 431

Answers (1)

hardcommitoneself
hardcommitoneself

Reputation: 1

I have faced same issue on my project. And finally I have resolved it by removing the getTableRecordKey function.

Please try it for you. And let me know if you have any errors.

Best

Upvotes: -1

Related Questions