Cgridview Button


i want to change the link of a button in cdridview depending on the category value

i am doing this:


            'class' => 'CButtonColumn',

            'template' => '{view}{update}{delete}',

            'buttons' => array


                'view' => array


                    'url' => '$model->category==0'?'Yii::app()->createUrl("project/viewlogo", array("id"=>$data->p_id))':'Yii::app()->createUrl("project/view", array("id"=>$data->p_id))',


            'afterDelete' => 'function(link,success,data){ if(success) $("#statusMsg").html(data);$(".success").animate({opacity: 1.0}, 4000).fadeOut("slow"); }',


but i am not gettin the url accordingly…


This is should be replaced

$model->category ==0

by this line


I hope it will work … cheers :)

thanks for the reply chandran… but i tried that and it’s not working

Try this first:

'url' => '$data->category==0?Yii::app()->createUrl("project/viewlogo", array("id"=>$data->p_id)):Yii::app()->createUrl("project/view", array("id"=>$data->p_id))',

if not working, move this part before the CGridView.

$vUrl='$data->category==0'?'Yii::app()->createUrl("project/viewlogo", array("id"=>$data->p_id))':'Yii::app()->createUrl("project/view", array("id"=>$data->p_id))';

Then in CGridView:





For your information

$model is not valid inside cgridview component. (i.e) $model is not evaluated… so you should use only $data

if you copy your whole page including $model … may be we can find solution :)