Reputation: 481
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?
Upvotes: 0
Views: 2164
Reputation: 5955
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
),
)
Upvotes: 2
Reputation: 5317
There is a document in here, you can check it.
By the way, document says, you can use url
parameter in Array
:
array(
'url' => '', //url comes here
),
Edit: Array must be out of columns
.
Upvotes: 0