Closed jmarkfen closed 11 months ago
If you're using an accessor column, you may pass sortable()
an array of database columns to sort by:
use Filament\Tables\Columns\TextColumn;
TextColumn::make('full_name')
->sortable(['first_name', 'last_name'])
Columns may be searchable by using the text input field in the top right of the table. To make a column searchable, you must use the searchable()
method:
use Filament\Tables\Columns\TextColumn;
TextColumn::make('name')
->searchable()
If you're using an accessor column, you may pass searchable() an array of database columns to search within:
use Filament\Tables\Columns\TextColumn;
TextColumn::make('full_name')
->searchable(['first_name', 'last_name'])
You may customize the placeholder in the search field using the searchPlaceholder() method on the $table:
use Filament\Tables\Table;
public static function table(Table $table): Table
{
return $table
->columns([
// ...
])
->searchPlaceholder('Search (ID, Name)');
}
You can choose to enable a per-column search input field using the isIndividual parameter:
use Filament\Tables\Columns\TextColumn;
TextColumn::make('name')
->searchable(isIndividual: true)
Sometimes you may want to display placeholder text for columns with an empty state, which is styled as a lighter gray text. This differs from the default value, as the placeholder is always text and not treated as if it were real state.
use Filament\Tables\Columns\TextColumn;
TextColumn::make('description')
->placeholder('No description.')
Users may hide or show columns themselves in the table. To make a column toggleable, use the toggleable() method:
use Filament\Tables\Columns\TextColumn;
TextColumn::make('email')
->toggleable()
Table columns are aligned to the start (left in LTR interfaces or right in RTL interfaces) by default. You may change the alignment using the alignment() method, and passing it Alignment::Start, Alignment::Center, Alignment::End or Alignment::Justify options:
use Filament\Support\Enums\Alignment;
use Filament\Tables\Columns\TextColumn;
TextColumn::make('email')
->alignment(Alignment::End)
Alternatively, you may use shorthand methods like alignEnd()
List residents (the latest record for each resident).
Columns:
Filters: