livewire-powergrid icon indicating copy to clipboard operation
livewire-powergrid copied to clipboard

[Bug]: Public method [exportToXLS] not found on component.

Open viniciusalvess opened this issue 3 years ago • 1 comments

Have you searched through other issues to see if your problem is already reported or has been fixed?

Yes, I did not find it.

Did you read the documentation?

Yes, I did not find it.

Have you tried to publish the views?

Yes, It didn't work.

Is there an error in the console?

No

PHP Version

8.1.19

PowerGrid

v4.6.1

Laravel

9.52.8

Livewire

2.12

Alpine JS

No response

Theme

Bootstrap

Describe the bug.

Started getting the exception below after upgrading from version 3.7.11 to 4.6.1. It is happening with csv export and xls.

image

Also found another issue on another app of mine that the export links on the dropdown are not preventing the default behavior of the link click and it is sending the page to the / of the app.

To Reproduce...

Just export all data

Extra information

<?php
namespace App\Http\Livewire\App;

use App\Models\AuditResource;
use Illuminate\Database\Eloquent\Builder;
use PowerComponents\LivewirePowerGrid\Column;
use PowerComponents\LivewirePowerGrid\Exportable;
use PowerComponents\LivewirePowerGrid\Footer;
use PowerComponents\LivewirePowerGrid\Header;
use PowerComponents\LivewirePowerGrid\PowerGrid;
use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\PowerGridEloquent;
use PowerComponents\LivewirePowerGrid\Traits\ActionButton;

final class AuditList extends PowerGridComponent
{
  use ActionButton;

  public function setUp(): array
  {
    $this->showCheckBox();

    return [
      Exportable::make('export')
        ->striped()
        ->type(Exportable::TYPE_XLS, Exportable::TYPE_CSV),
      Header::make()->showSearchInput(),

      Footer::make()
        ->showPerPage()
        ->showRecordCount(),
    ];
  }

  public function datasource(): Builder
  {
    return AuditResource::query();
  }

  public function relationSearch(): array
  {
    return [];
  }


  public function addColumns(): PowerGridEloquent
  {
    return PowerGrid::eloquent()
      ->addColumn('id')
      ->addColumn('user_type')
      ->addColumn('user_id')
      ->addColumn('event')
      ->addColumn('auditable_type')
      ->addColumn('auditable_id')
//      ->addColumn('name_lower', fn(Account $model) => strtolower(e($model->name)));
      ->addColumn('created_at');
//      ->addColumn('created_at_formatted', fn(Account $model) => Carbon::parse($model->created_at)->format('d/m/Y H:i:s'));
  }

  public function columns(): array
  {
    return [
      Column::make(__('ID'), 'id')
        ->searchable()
        ->sortable(),

      Column::make(__('User Type'), 'user_type')
        ->searchable()
        ->sortable(),

      Column::make(__('User Id'), 'user_id')
        ->searchable()
        ->sortable(),

      Column::make(__('Event'), 'event')
        ->searchable()
        ->sortable(),

      Column::make(__('Auditable Type'), 'auditable_type')
        ->searchable()
        ->sortable(),

      Column::make(__('Auditable Id'), 'auditable_id')
        ->searchable()
        ->sortable(),


      Column::make(__('Created at'), 'created_at', 'created_at')
        ->searchable()
    ];
  }

  public function header(): array
  {
    return [];
  }

  public function actions(): array
  {
    return [];
  }}

viniciusalvess avatar Jun 06 '23 05:06 viniciusalvess

Hello!, please see upgrade-guide.

https://v4.livewire-powergrid.com/get-started/upgrade-guide.html#independent-export-engine

luanfreitasdev avatar Jun 07 '23 14:06 luanfreitasdev