Component as row in TableBuilder

I have a table with a custom View for the row as follows:
->columns([View::make('components.***')
->components([
Tables\Columns\TextColumn::make('date')
->searchable(),
Tables\Columns\TextColumn::make('a.name')
->searchable(),
Tables\Columns\TextColumn::make('b.name')
->searchable(),
]),
->columns([View::make('components.***')
->components([
Tables\Columns\TextColumn::make('date')
->searchable(),
Tables\Columns\TextColumn::make('a.name')
->searchable(),
Tables\Columns\TextColumn::make('b.name')
->searchable(),
]),
this renders the view correctly. But this view is just one part of the component, there is also the
namespace App\Livewire;
use Livewire\Component;
class *** extends Component
{
public $propertyA = false;
public $propertyB = true;
namespace App\Livewire;
use Livewire\Component;
class *** extends Component
{
public $propertyA = false;
public $propertyB = true;
Because the filament table only renders the view and does not use the component the properties are not available inside the blade view. It is working if i set the properties above the html code inside the blade view via:
@php
if (!isset($propertyA)) {
$propertyA= false;
}
@endphp
<div x-data="{ original_text: false }" class="">
...
@php
if (!isset($propertyA)) {
$propertyA= false;
}
@endphp
<div x-data="{ original_text: false }" class="">
...
But i would like to render the whole component as my table row because i am using this component also in other parts of my application with the properties inside the component and not the blade view. Is that possible anyhow? Thanks in advance
Solution:
I think you can render the LW component in the view that you created ```html <div> <livewire::your-component />...
Jump to solution
4 Replies
LeandroFerreira
LeandroFerreira6mo ago
this is a view, not a LW component. If you want to add custom properties, you should add in the ListPage ListPage
public $propertyA = false;
public $propertyA = false;
View
<div>
{{ $this->propertyA }}
</div>
<div>
{{ $this->propertyA }}
</div>
ArnoNym
ArnoNymOP6mo ago
Thanks for the very quick reply. I am using this component also in other places in the application and i want to reuse/share the view because the view is the same no matter where the row is shown. Sometimes in filament table, sometimes in other blade views via:
<livewire:*** :propertyA="$A" :propertyB="false" :wire:key="$loop->index" />
<livewire:*** :propertyA="$A" :propertyB="false" :wire:key="$loop->index" />
So is there a way to render a component inside the filament table as row or do i need to set the default values for the properties in the blade view and again in the component? Thanks alot
Solution
LeandroFerreira
LeandroFerreira6mo ago
I think you can render the LW component in the view that you created
<div>
<livewire::your-component />
@livewire('your-component')
</div>
<div>
<livewire::your-component />
@livewire('your-component')
</div>
ArnoNym
ArnoNymOP6mo ago
awesome. why didnt i think about that. I made a wrapper blade view with just the div and <livewire:: ... inside. Thanks alot
Want results from more Discord servers?
Add your server