How to disable toggables on table?

Hi guys, I have multiple resuable columns, but on some tables I want to disable toggability of that table. I know, I can set $table->searchable(false) to disable searchbar, but how to disable button for toggling columns on table (not on separate columns)?
4 Replies
Patrick Boivin
Patrick Boivin9mo ago
How are you reusing the columns?
TranceCode
TranceCode9mo ago
@Trauma Zombie try with ->disabled()
Tables\Columns\ToggleColumn::make('active')
->label('Cuenta activa')
->disabled()
->sortable(),
Tables\Columns\ToggleColumn::make('active')
->label('Cuenta activa')
->disabled()
->sortable(),
Trauma Zombie
Trauma ZombieOP9mo ago
public function table(Table $table): Table
{
return parent::table($table)
->columns(DiagnosisTable::getColumns())
->filters([
//
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
])
->searchable(false) // working
->toggleable(false); // not working
}
public function table(Table $table): Table
{
return parent::table($table)
->columns(DiagnosisTable::getColumns())
->filters([
//
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
])
->searchable(false) // working
->toggleable(false); // not working
}
I extract all columns to separete class and method, so I can reuse it and I dont need to duplicate my code.
Patrick Boivin
Patrick Boivin9mo ago
Maybe DiagnosisTable::getColumns(toggleable: false), and then you can forward it to all the columns? I'm not sure there is a method on the table directly.

Did you find this page helpful?