lilbiscuit
lilbiscuit

Reputation: 2249

Best way to format currency in Yii gridview with no decimals

Can Yii formatCurrency be used to format a currency value in cGridView with zero decimal places?

My current code is:

Yii::app()->locale->numberFormatter->'.'formatCurrency($data["'.$columnName.'"],Yii::app()->params->currency)

Which results in:

$50,000.00

And I want the result to be:

$50,000

Upvotes: 1

Views: 2761

Answers (1)

Kumar V
Kumar V

Reputation: 8838

Same problem discussed in Yii forum. Here I added some points. Please check the relevant link.

This is due to your locale currency settings. Go and check your YII framework folder/i18n/data you will fix the problem there... Find your locale and fix it.

In ii18n/Cnumberformatter.php change line 162

$value=round($value,$format['maxDecimalDigits']);

to

$value=number_format($value,$format['maxDecimalDigits'],'.','');

refer this forum.

http://www.yiiframework.com/forum/index.php/topic/21002-formatcurrency-broken/

Upvotes: 1

Related Questions