Skip to content

setThAttributes if Column is a specific Label() #1093

Closed Answered by lrljoe
BenOussama180 asked this question in Q&A
Discussion options

You must be logged in to vote

If you're targeting a specific column, you can use:

$column->getTitle() == 'Your Column Title'

e.g.

->setThAttributes(function (Column $column) {
                if ($column->isLabel() && $column->getTitle() == 'Your Column Title') {
                    return [
                        'class' => 'bg-red-500 font-bold text-white',
                    ];
                }
                return [];
            })

Any Field methods (e.g. "isField") won't apply to a Label-only Column, as there is no related DB field, but will apply if there's an underlying field. I'd recommend using getTitle() for consistency with isLabel().

Replies: 1 comment

Comment options

lrljoe
Mar 9, 2023
Collaborator Sponsor

You must be logged in to vote
0 replies
Answer selected by BenOussama180
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants