Skip to content

Question - set bodyAttribute of column based on the row value #771

Answered by dansysanalyst
dr3nyl asked this question in Q&A
Discussion options

You must be logged in to vote

You can use Action Rules, it might look something like this:

final class MyTable extends PowerGridComponent
{
//...
 public function actionRules(): array
    {
        return [
            Rule::rows()
                ->when(fn($user) => (bool) $user->is_active === false)
                ->setAttribute('class', 'bg-yellow-50 hover:bg-red-100'),

            Rule::rows()
                ->when(fn($user) => (bool) $user->is_active === true)
                ->setAttribute('class', 'bg-yellow-50 hover:bg-green-100')
        ];
    }

Also, you may check the classes in the default themes at your directory: vendor/power-components/livewire-powergrid/src/Themes/, more info on custom themes in the…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@younus93
Comment options

Answer selected by luanfreitasdev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #770 on December 19, 2022 13:35.