format number in Gridview

I have defined a column in Database as float.

The column is being shown as number in the model.

I want to format the columnn in Gridview with two decimal places and couldn’t find a way, how it can be done.

I have tried to use this code but getting the error like - Unknown format type: number


             'label' => 'Charges',

            'attribute' =>'category_charges',

            'contentOptions' => ['class' => 'col-lg-1'],


                'format' => ['number',2] 


Note I can achieve the same using custom function, but I am sure i.e. not the best method.


<?php $this->widget(‘zii.widgets.grid.CGridView’, array(







'name' =&gt; 'column_name',

'value' =&gt; 'number_format(&#036;data-&gt;column_name,2)',

), // display number upto 2-decimal format





)); ?>

Try this out and like if you agree. :D