How To Show $ (Dollar) Character In Cgridview Column Value

Hi Guys - I am having below column in CGridView widget:




array(

  'name'=>'cost',

  'header'=>'Cost',

  'value'=>'Yii::app()->params["currencyFormat"].isset($data->defaultVendor["0"]->purchase_price)?$data->defaultVendor["0"]->purchase_price:null'

),



since, value is being calculated, I need to show “Dollar Sign” in front of it’s value. HOw I can append it?

No doubt, I can append string functions like substr or chr etc. But those are also not working, I have tried below statement also:




array('name'=>'cost',

 'header'=>'Cost',

 'value'=>'chr(36).Yii::app()->params["currencyFormat"].isset($data->defaultVendor["0"]->purchase_price)?$data->defaultVendor["0"]->purchase_price:null'

),

Thanks,

add ‘type’ => ‘raw’ in column array

You might do better putting this logic into an anonymous function.




array('name'=>'cost',

    'header'=>'Cost',

    'value'=>function($data){

        $purchasePrice = isset($data->defaultVendor["0"]->purchase_price)

                       ? $data->defaultVendor["0"]->purchase_price

                       : null;

        return '$' . Yii::app()->params["currencyFormat"] . $purchasePrice;

    },

),



It would at least make the logic clearer, which might prevent problems when determining how to add the symbol.