CLinkColumn和过滤器

I use framework YII. I will do link for e-mail in my list from GRID. I added this:

array(
    'class'=>'CLinkColumn',
    'header'=>'e-mail',
    'labelExpression'=>'$data->email',
    'urlExpression'=>'"mailto:".$data->email',
),

this working ok, but now i dont hava column filter. CLinkColumns doesnt has method filter. How can i make link mailto: and use filter for this?

give it a shot like this --

array(
  'class'=>'CLinkColumn',
  'header'=>'e-mail',
  'labelExpression'=>'$data["email"]',
  'urlExpression'=>'"mailto:".$data["email"]',
),

You could also try something like this:

array(
   'name' => 'email',
   'header' => 'e-mail',
   'type' => 'raw',
   'value' => 'CHtml::link($data->email,"mailto:".$data->email)'
),

You can't use a filter with CLinkColumn.


The Yii developers discussed adding 'name' to CLinkColumn here: https://github.com/yiisoft/yii/pull/970

They decided against it:

... there is no need to "complicate" [CLinkColumn] further as that would be just a duplication of code or "hacks" to solve issues...

samdark says:

CLinkColumn will be there for simple usage only . If you need more options, consider using value.

This is their recommended alternative:

array(
  'name' => 'field_name',
  'type' => 'raw',
  'value' => 'CHtml::link($data->field_name,$data->field_name)'
),