table row background color & clear all filters button

Hi there. I need to things: 1. i want my first 4 records in the table to have green background and the last 4 records a red background. How can i achievie that? 2. i'd like to disable or completly remove button to clear filters in table.
4 Replies
charlie
charlie3w ago
the first 4 no matter how they're sorted?
SnaggyDainc
SnaggyDaincOP3w ago
I could disable sorting if needed. You’ve got any idea how can I do that? It’s basically a sport table, I want top teams to have custom colours and the worse teams too
charlie
charlie3w ago
ok. I mean if you don't sort, you can do it with simple CSS but only for the first 4.
/* First 4 are green */
.fi-ta-row:nth-child(1), .fi-ta-row:nth-child(2), .fi-ta-row:nth-child(3), .fi-ta-row:nth-child(4) {
background-color: rgba(34, 197, 94, 0.3);
}
/* First 4 are green */
.fi-ta-row:nth-child(1), .fi-ta-row:nth-child(2), .fi-ta-row:nth-child(3), .fi-ta-row:nth-child(4) {
background-color: rgba(34, 197, 94, 0.3);
}
But for the last four it's not possible in CSS because of pagination. However, you could do that on php side with recordClasses :
->recordClasses(fn(YourModel $record) => match (true) {
$record->isInTop4() => 'border-s-2 !border-s-green-600 !dark:border-s-green-300',
$record->isInBottom4() => 'border-s-2 !border-s-red-600 !dark:border-s-red-300',
default => '',
})
->recordClasses(fn(YourModel $record) => match (true) {
$record->isInTop4() => 'border-s-2 !border-s-green-600 !dark:border-s-green-300',
$record->isInBottom4() => 'border-s-2 !border-s-red-600 !dark:border-s-red-300',
default => '',
})
you may need a custom theme if you use tailwind classes that haven't been used yet by filament
SnaggyDainc
SnaggyDaincOP3w ago
Thank you very much, I will try it out! i found out i can also do something like this:
->state(static function ($rowLoop) {
$numOfRecords = $rowLoop->count;
if($rowLoop->iteration <= 4) {
return 'green';
}
->state(static function ($rowLoop) {
$numOfRecords = $rowLoop->count;
if($rowLoop->iteration <= 4) {
return 'green';
}
and form my 2nd question this do part of the job:
->hiddenFilterIndicators(true)
->hiddenFilterIndicators(true)

Did you find this page helpful?