I did everything according to the available documentation but lazy loading still does not work https://livewire-powergrid.com/table-component/component-configuration.html#lazy-loading i get errors: Uncaught ReferenceError: $item is not defined at [Alpine] $item (eval at safeAsyncFunction (livewire.js?id=cc800bf4:1176:21),
:3:32)Alpine Expression Error: $item is not defined
Expression: “$item”
<livewire:lazy-child key=”bd47ef2b1fbba808b5f338c39f1043a9″ :child-index=”$item” :$this->…</livewire:lazy-child>
<?php
namespace AppLivewire;
use AppModelsUser;
use IlluminateSupportCarbon;
use IlluminateDatabaseEloquentBuilder;
use PowerComponentsLivewirePowerGridButton;
use PowerComponentsLivewirePowerGridColumn;
use PowerComponentsLivewirePowerGridExportable;
use PowerComponentsLivewirePowerGridFacadesFilter;
use PowerComponentsLivewirePowerGridFooter;
use PowerComponentsLivewirePowerGridHeader;
use PowerComponentsLivewirePowerGridPowerGrid;
use PowerComponentsLivewirePowerGridPowerGridFields;
use PowerComponentsLivewirePowerGridPowerGridComponent;
use PowerComponentsLivewirePowerGridTraitsWithExport;
use IlluminateSupportFacadesAuth;
use AppLivewireAdminUSerUserIndex;
use AppHelpersPermissionHelper;
use PowerComponentsLivewirePowerGridFacadesRule;
use IlluminateSupportFacadesBlade;
use PowerComponentsLivewirePowerGridLazy;
final class UserTable extends PowerGridComponent
{
use WithExport;
public string $tableName = 'UserAdminTable';
public $selectRowUser = 0;
public function setUp(): array
{
$this->showCheckBox();
return [
Exportable::make('export')
->striped()
->type(Exportable::TYPE_XLS, Exportable::TYPE_CSV),
Header::make()->showSearchInput(),
Footer::make()
->showRecordCount()
->showRecordCount(),
Lazy::make()
->rowsPerChildren(25),
];
}
public function template(): ?string
{
return AppPowerGridThemesSmallFontTheme::class;
}
public function datasource(): Builder
{
$this->showAllUser= session()->get('showAllUser');
if ($this->showAllUser) {
return User::query();
} else {
return User::query()->where('is_active', 1);
}
}
public function relationSearch(): array
{
return [];
}
public function fields(): PowerGridFields
{
return PowerGrid::fields()
->add('selectButton', function ($row) {
return Blade::render('
<button
class="btn bg-gray-300 btn-xs mx-2"
>
Wybierz
</button>');
})
->add('burger', function ($row) {
$deleteLabel = $row->is_active == 1 ? 'Dezaktywuj' : 'Aktywuj';
return Blade::render(
'dropdown button code here'
);
})
->add('user_name')
->add('email')
->add('first_name')
->add('last_name')
->add('is_active', fn ($prop) => e($prop->is_active == 1 ? 'Aktywne' : 'Dezaktywowane'));
}
public function columns(): array
{
return [
Column::make('Wybierz', 'selectButton')->bodyAttribute('sticky left-0')
->headerAttribute('sticky left-0 h-fit'),
Column::make('Opcje', 'burger'),
Column::make('Login', 'user_name')
->sortable()
->searchable(),
Column::make('Imię', 'first_name')
->sortable()
->searchable(),
Column::make('Nazwisko', 'last_name')
->sortable()
->searchable(),
Column::make('Email', 'email')
->sortable()
->searchable(),
];
}
#[LivewireAttributesOn('editUser')]
public function edit($rowId, $userName): void
{
$this->dispatch('editUser', [$rowId, $userName])->to(UserIndex::class);
}
#[LivewireAttributesOn('selectUser')]
public function select($rowId): void
{
$this->selectRowUser = $rowId;
$this->dispatch('selectUser', [$rowId])->to(UserIndex::class);
}
#[LivewireAttributesOn('addProfile')]
public function addProfile($rowId, $userName, $symbol): void
{
$this->dispatch('addProfile', [$rowId, $userName, $symbol])->to(UserIndex::class);
}
}