[Solved] - Check A Condition In Cbutton Column - Possible?

hello guys,

I was wondering whether its possible to check a condition in the cbutton column.

The code part is as follows :




array(

                                    'class' => 'CButtonColumn',

                                    'header' => '',

                                    'htmlOptions' => array('class' => 'width110'),

                                    'headerHtmlOptions'=>array('class' => 'width110'),

                                    'template' => '($data->weblinkId) ==1 ? {edit} : {delete}',

                                    'buttons' => array(

                                        'edit' => array(

                                            'label'=>'',     // text label of the button

                                            'url'=>'Yii::app()->createUrl("user/editweblink",  array("id"=>$data->weblinkId))',       // the PHP expression for generating the URL of the button

                                            'visible' => '$data->weblinkId',

                                            'options'=>array('class'=>'profile-edit-btn'), // HTML options for the button tag


                                        ),

                                        'delete' => array(

                                            'label'=>'',     // text label of the button

                                            'url'=>'Yii::app()->createUrl("user/removeweblink", array("id"=>$data->weblinkId))',       // the PHP expression for generating the URL of the button

                                            'visible' => '$data->weblinkId',

                                            'deleteConfirmation'=>'Are you sure you want to delete this record',                      

                                            'options'=>array('class'=>'delete-btn'), // HTML options for the button tag

                                        ),                                    

                                    ),

                                ),



Is something similar like this possible or is there any other way which i can get this done?




'template' => '($data->weblinkId) ==1 ? {edit} : {delete}',



Cheers.

Got it…





'buttons' => array(

                                        'copy' => array(

                                            'label'=>'',     // text label of the button

                                            'url'=>'Yii::app()->createUrl("user/newnotification",  array("id"=>$data->notificationId))',       // the PHP expression for generating the URL of the button

                                            'visible' => '$data->notificationId',

                                            'options'=>array('class'=>'file-btn'), // HTML options for the button tag

                                            'visible'=>'($data->status == 1)||($data->status == 2)',


                                        ),

                                        'edit' => array(

                                            'label'=>'',     // text label of the button

                                            'url'=>'Yii::app()->createUrl("user/editnotification",  array("id"=>$data->notificationId))',       // the PHP expression for generating the URL of the button

                                            'visible' => '$data->notificationId',

                                            'options'=>array('class'=>'profile-edit-btn'), // HTML options for the button tag

                                            'visible'=>'$data->status == 0',


                                        ),

                                        'publish' => array(

                                            'label'=>'',     // text label of the button

                                            'url'=>'Yii::app()->createUrl("user/publishnotification", array("id"=>$data->notificationId))',       // the PHP expression for generating the URL of the button

                                            'visible' => '$data->notificationId',                     

                                            'options'=>array('class'=>'publish-button'), // HTML options for the button tag

                                            'visible'=>'$data->status == 0',

                                        ),                                    

                                    ),      




Visible Tag :




'visible'=>'$data->status == 0',