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.

Thanks.

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

‘id’=>‘comments-grid’,

‘dataProvider’=>$model->search(),

‘filter’=>$model,

‘columns’=>array(

‘intId’,

array(

'name' =&gt; 'column_name',


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

), // display number upto 2-decimal format

array(

‘class’=>‘CButtonColumn’,

),

),

)); ?>

Try this out and like if you agree. :D