0

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?

Kai
  • 38,985
  • 14
  • 88
  • 103
ChUck_PrOg
  • 331
  • 7
  • 16

2 Answers2

2

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
   ),
)
acorncom
  • 5,975
  • 1
  • 19
  • 31
0

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.

Ogulcan Orhan
  • 5,170
  • 6
  • 33
  • 49