Add functionality tr class in table#149
Conversation
|
Hi @joserojasrodriguez thanks for raising this, I have some comments/questions
Thanks |
| <tbody> | ||
| @foreach ($items as $item) | ||
| <tr class="border-b border-gray-200 text-sm" wire:key="{{ $item->getKey() }}"> | ||
| <tr class="border-b border-gray-200 text-sm {{$view->trClass($item)}}" wire:key="{{ $item->getKey() }}"> |
There was a problem hiding this comment.
With this approach, I think we are forcing all the components to have this method defined, in that case, there should be a validation to execute this only if it's defined, or maybe adding a default value
There was a problem hiding this comment.
Hello @Gustavinho this functionality is to be able to give a css class to a tr, for example
public funtion trClass($model)
{
if($model->status == 'VA')
{
return 'bg-green';
}
return '';
}
There was a problem hiding this comment.
The tables are only in the table component so I think the other components would not be affected.
Although that method returns an empty string anyway
There was a problem hiding this comment.
Thanks @joserojasrodriguez , I see what you're trying to do, it's cool, by "components" I meant "views" or Livewire components, I think if we don't define that trClass() method in our table view files, it will throw an error, even if we don't need to customize the tr class, this method will have to be there, I saw you added it in the pub file but what happens with the current projects and files already created?, we will have to add that method to all of our files, even returning an empty string, you had to do it with the mocked table views for testing, this is for retro compatibility with views already created, what I'm trying to say is that this method shouldn't be mandatory.
| return []; | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
I think it would be better to remove this from the stub file and add it to the documentation
Add method for add custom class to tr on table.