Closed hgferreira closed 3 years ago
If I understand your request, you should be able to do this by overriding the _columns.blade.php file.
Currently there is no way to publish the views from this package via an artisan command. However, I have submitted a pull request to make it possible.
Until the pull request is approved, you can manually copy everything in vendor/rappasoft/laravel-livewire-tables/resources/views/ to resources/views/vendor/laravel-livewire-tables/.
The file you'll want to edit is resources/views/vendor/laravel-livewire-tables/includes/_columns.blade.php
Consider the column "primary" that is true or false. We might want to change the output to display something else instead of 0 and 1, an option that allows to display an icon, image or basicly a string that allow us to do just that. It will nice if we can include the original value in that string also, this will allow adding some icon or formating to the output text,
This can be done using the ->view()
method.
Consider the column "primary" that is true or false. We might want to change the output to display something else instead of 0 and 1, an option that allows to display an icon, image or basicly a string that allow us to do just that. It will nice if we can include the original value in that string also, this will allow adding some icon or formating to the output text,
This can be done using the
->view()
method.
Can you elaborate on this a bit? How does the view know what the row data is?
Also how can we make it work for any attribute? E.g I have a time stamp and want a view that converts it into a certain date format, or money in cents that I want to display as a formatted string, and how do you maintain the flexibility of different attribute names. For example, say I want to format created_at
so I put that in the view. What about if I want to apply the same component to updated_at
now, or another custom date attribute name?
Currently to me it seems like I would have to make a separate view for each, and that approach doesn’t seem very flexible and seems far too opinionated for people who want to use this pkg in a bunch of different projects.
I mentioned in another issue I created that this could be made quite significantly better by allowing a callback on the Column::make function that allows you to access the row data and mutate it however you need before it’s displayed in the table.
Hi,
Consider the column "primary" that is true or false. We might want to change the output to display something else instead of 0 and 1, an option that allows to display an icon, image or basicly a string that allow us to do just that. It will nice if we can include the original value in that string also, this will allow adding some icon or formating to the output text,
Cheers and very good work