2012-03-08 5 views
0

CGridview内のリンクを変更するにはどうすればよいですか?yii CButton Column

これが私の見解ページからである。その後、

$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', 
    ), 
) 
)); 

私のコンポーネントから:私は私CGridviewのビューボタンをクリックすると、「たとえば」が起こるしたいもの

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

、それ私をhttp://www.google.com?action=someactionにリダイレクトします。これどうやってするの?

+0

私の答えがあなたの問題を解決すれば、私はupvoteをいただければ幸いです。どうも! – acorncom

答えて

2

ボタンクラスは別途必要ありません。

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

hereに文書があります。確認できます。

ちなみに、ドキュメントはArrayurlパラメータを使用することができ、こう述べています。

array(
    'url' => '', //url comes here 
), 

編集:配列はcolumnsの外にでなければなりません。