Power-Components / livewire-powergrid

⚡ PowerGrid generates modern, powerful and easy-to-customize data tables using Laravel Livewire.

Home Page:https://livewire-powergrid.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Formatting multiple columns with summarizeFormat()

dansysanalyst opened this issue · comments

commented

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

No response

PowerGrid

No response

Laravel

No response

Livewire

No response

Alpine JS

No response

Theme

Tailwind 3.x

Describe the bug.

No response

To Reproduce...

I would like to format the average summary in two different columns, one as a kcal and the other as currency $.

Expected:

IMAGE 2024-05-05 11:06:47


Result:

IMAGE 2024-05-05 11:06:49

Extra information

Column::make('Calories', 'calories', 'calories')
                ->withAvg('Average', header: true, footer: false)
                ->sortable(),

Column::make('Price', 'price_formatted', 'price')
                ->withSum('Sum Price', header: true, footer: false)
                ->withAvg('Avg Price', header: true, footer: false)
public function summarizeFormat(): array
{
    return [
        'calories.{avg}'          => fn ($value) => Number::format($value, locale: 'br') . ' kcal',
        'price.{sum,avg,min,max}' => fn ($value) => Number::currency($value, in: 'USD'),
        'price.{count}'           => fn ($value) => Number::format($value, locale: 'br'),
    ];
}
commented

I should be sending a PR soon fixing this issue.

commented

Fixed in v5.6.0