#Issue on filament tables grouping rows when upgrade from v3 to v4.

2 messages · Page 1 of 1 (latest)

hoary inlet
#

How to group the record which value may or may not be always present on table.

Row grouping code:
Group::make('unscopedParent.name')
->label('Parent Client')
->collapsible(),

Table column:
TextColumn::make('unscopedParent.name')
->hiddenOn(ManageChildClients::class)
->label('Parent')
->url(function ($record, TextColumn $column) {
$record->load('parent');
if (Tenant::user()->can('view_client') && $record->parent) {
FilamentHelper::applyUrlStyle($column);

                    return ClientResource::getUrl('child-clients', [
                        'record' => $record->parent_id,
                    ]);
                }
            })
            ->numeric()
            ->sortable(),

Relation in model:

/**
* @return BelongsTo<Client, $this>
**/
public function parent(): BelongsTo
{
return $this->belongsTo(Client::class, 'parent_id');
}

/**
 * @return BelongsTo<Client, $this>
 **/
public function unscopedParent(): BelongsTo
{
    return $this->parent()->withoutGlobalScopes();
}
silk thicketBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution