如何修改CGridview中的链接?
这是来自我的视图页面:
$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',
),
)
));然后从我的组件中:
class ViewOnly extends CButtonColumn {
public $template = '{view}';
}例如,如果我单击CGridview中的查看按钮,它会将我重定向到http://www.google.com?action=someaction。我该怎么做呢?
发布于 2012-04-01 14:45:40
您不需要单独的按钮类。这样做:
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
),
)发布于 2012-03-09 00:09:20
在here中有一个文档,你可以查看它。
顺便说一下,文档说,您可以在Array中使用url参数
array(
'url' => '', //url comes here
),编辑:数组必须不在columns中。
https://stackoverflow.com/questions/9620741
复制相似问题