Reputation: 11
I'm currently working on Laravel-admin project with laravel9.
For instance, If the value = 'error', I want to change the background color of the column. Something like this pic:
My code is this:
$grid->column('title')->display(function ($title, $column) {
if ($title !== 'error') {
return $title;
}
return $column->setAttributes(['style' => 'background-color:red;']);
});
But seems like I can't use setAttributes()
method on $column
.
Also If I use setAttributes(['style' => 'background-color:red;'])
the column name(In this case title) become red as well.
Any advice would be appreciated.
I read the Laravel-admin document and searched for a solution for hours but I couldn't find any good info.
Upvotes: 1
Views: 421