默认显示的内容是没有链接的,现在想加链接,效果图如下
代码位置就在columns数组里,直接上代码说明
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'news-grid',
'dataProvider' => $data,
'filter' => $model,
'columns' => array(
'nid',
// 'n_title',
array(
'name' => 'n_title',
'type' => 'raw',
'value' => 'CHtml::link($data->n_title,array("/news/detail","id" => $data->nid))',
),
array(
'class'=>'CButtonColumn',
'template'=>'{update}{delete}',
//自定义删除提示
'deleteConfirmation'=>"js:'ID为 '+$(this).parent().parent().children(':first-child').text()+' 的记录将被删除,确定删除?'",
),
),
));
就是这段代码了
array
(
'name'
=>
'n_title'
,
'type'
=>
'raw'
,
'value'
=>
'CHtml::link($data->n_title,array("/news/detail","id" => $data->nid))'
,
参考的内容有
http://www.yiiframework.com/forum/index.php/topic/23211-clinkcolumn-in-cgridview/ (这个主要是对 CLinkColumn 的讲解,配置项比较繁琐,可以了解一下也不错)