urlyiicbuttoncolumncbutton

yii CButton Column


How do i modify the links inside the CGridview?

This is from my view page:

$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$new,
'columns'=>array(
'book.title',
'book.author',
'book.edition',
'date_borrowed',
'borrowed_status',
'date_returned',
'returned_status',
    array(
        'class'=>'Viewonly',
    ),
)
));

then from my Components:

class ViewOnly extends CButtonColumn {
    public $template = '{view}';
}

what i want to happen "FOR EXAMPLE" if i click the view button in my CGridview, it will redirect me to http://www.google.com?action=someaction. how can i do this?


Solution

  • You don't need a separate button class. Do something like this:

    array(
       'class'=>'CButtonColumn',
       'template'=>'{view} {google}',
       'viewButtonUrl=>'Yii::app()->createUrl("http://google.com/",array("q"=>$data->name))',
       'google'=>array(
          ... Init code for this button here
       ),
    )