[Solved] Cgridview Number Formatting

Hey all.

I have my figures saved in a database. I want, when i display them using CGridView, I, they are formatted, and commas added for example, if the number saved in the database is 23654789, what is displayed is 23,654,789.

Thanks in Advance

Been doing research about this. I found this.

When i do something like this


<?php  $sammie=Yii::app()->format->number(1235426358);	echo $sammie; ?>

, it returns the value well formatted, that is 1,235,426,358 , which is what i want.

The problem now is, the value i want formatted is returned from execution of a query and displayed using Gridview like this


'unit_price'=>array('name'=>'Unit Price(UGX)', 'value'=>'$data["unit_price"]', 'htmlOptions'=>array('style' => 'text-align: right;')),

.

How do i now do the number formatting, so the value displayed in the gridview is formatted??? :(

Problem solved.

After reading this, i realized that all i had to do was to add a "type" attribute to the column. Just changed this


'unit_price'=>array('name'=>'Unit Price(UGX)', 'value'=>'$data["unit_price"]', 'htmlOptions'=>array('style' => 'text-align: right;')),

to this


'unit_price'=>array('type'=>'number','name'=>'Unit Price(UGX)', 'value'=>'$data["unit_price"]', 'htmlOptions'=>array('style' => 'text-align: right;')),

;D

Good work in tracking the answer down on your own 8)

As well as sharing the answer for others.

Thank you for appreciating ;)