Power-Components / livewire-powergrid

⚡ PowerGrid generates modern, powerful and easy-to-customize data tables using Laravel Livewire.
https://livewire-powergrid.com
MIT License
1.41k stars 205 forks source link

exporting a table with a collection just export the first page #1488

Closed marineusde closed 3 months ago

marineusde commented 3 months ago

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 - I didn't work.

Is there an error in the console?

No

PHP Version

8.2.7

PowerGrid

5.4.8

Laravel

10.48.4

Livewire

3.4.9

Alpine JS

No response

Theme

Bootstrap

Describe the bug.

Try

To Reproduce...

final class TestTable extends PowerGridComponent
{
    use WithExport;

    public function datasource(): ?Collection
    {
        $collection = new Collection;
        for ($i = 1; $i <= 20; $i++) {
            $collection->add([
                'id' => $i,
                'name' => 'Name ' . $i
            ]);
        }

        // Have to do this to get paginating
        $this->total = $collection->count();

        return $collection;
    }

    public function setUp(): array
    {
        return [
            Exportable::make('export')
                ->striped()
                ->type(Exportable::TYPE_XLS),
            Header::make()->showSearchInput(),
            Footer::make()
                ->showPerPage()
                ->showRecordCount(),
        ];
    }

    public function fields(): PowerGridFields
    {
        return PowerGrid::fields()
            ->add('id')
            ->add('name');
    }

    public function columns(): array
    {
        return [
            Column::make('ID', 'id'),

            Column::make('Name', 'name'),
        ];
    }
}

Extra information

No response

luanfreitasdev commented 3 months ago

Thank you @zwhhz !

luanfreitasdev commented 3 months ago

Released: https://github.com/Power-Components/livewire-powergrid/releases/tag/v5.4.9