Power-Components / livewire-powergrid

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

Issue while exporting the table data after sorting by a column which was provided as an alias #1669

Closed YashShah20 closed 2 months ago

YashShah20 commented 2 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.0.2

PowerGrid

3.2

Laravel

9.19

Livewire

2.10

Alpine JS

No response

Theme

Bootstrap

Describe the bug.

Getting error while exporting the table data when sorting the table by a column let's say 'contract_name' which is not directly in the table used in the datasource let's say 'action_letters' but has been added with a join from other table .

To Reproduce...

datasource should have joins and one column name should be aliased to a diffrent name which will be used in Column::add() method

Sort by this column name and try to export

The following error will be generated by this SQLSTATE[42S22]: Column not found: 1054 Unknown colum

Extra information

No response

luanfreitasdev commented 2 months ago

To sort columns in joined tables, you need to assign an alias to the column in the datasource select and reference it in the addColumns method (fields 6.x).

For more details, refer to the example in the documentation. If you believe this issue persists, please create a repository with a more detailed example, and we'll investigate further.

https://livewire-powergrid.com/table-component/data-source.html#join-tables

Thank you