Question

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?

Was it helpful?

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
   ),
)

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top