Yii TBGridview 中的十进制格式

Decimal Format in Yii TBGridview

我有这样的代码:

<?php 
$this->widget('bootstrap.widgets.TbGridView',array(
'id'=>'appliances-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
        array(
            'name'=>'price',
            'type'=>'number',
            'htmlOptions'=>array('style' => 'text-align: right;'),
        ),
        array(
            'class'=>'bootstrap.widgets.TbButtonColumn',
            'template'=>'{update}{delete}'
        ),
    ),
)); 
?>

结果仅为整数且搜索过滤器有效,如何将其更改为小数格式但搜索过滤器仍然有效?
我试图将其更改为:

array(
    'name'=>'price',
    'type'=>'number',
    'htmlOptions'=>array('style' => 'text-align: right;'),
    'value'=>function($data)
             {
                return number_format($data->price,2,',','.');
             },
),

但这会使搜索过滤器无法正常工作。

我在这里找到了答案:

  1. Yii Number Formatting
  2. How to format numeric string using C.Gridview - Yii

我还发现了这个 link Yii , show different date format in cgridview

Try This:-  
  $this->widget('zii.widgets.grid.CGridView', array(
        'dataProvider' => $dataProvider,
        'columns'      => array(
            'cost',          // display the 'cost' attribute
            array(           // display the 'cost_in_dollars' using an expression
                'name'  =>  'cost_in_dollars',
                'value' =>  'number_format($data->cost/100, 2)',
            ),
        ),
    ));