setThAttributes if Column is a specific Label() #1093
-
so i have 4 labels in my table component :
when i apply classes using :
it applies too all the label fields, i want to apply specific colors to specific fields for example red to expenses , green to live ..etc, how can i achieve that ? the isField method is not working at all & i dont know how to use isColumn method |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
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(). |
Beta Was this translation helpful? Give feedback.
If you're targeting a specific column, you can use:
e.g.
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().