如何在Yii中为GRIDVIEW中的每一行添加标题标记

如何在Yii中为GRIDVIEW中的每一行添加标题标记,gridview,yii,cgridview,Gridview,Yii,Cgridview,我想为Gridview中的每一行添加标题属性。 我有什么办法可以让它工作吗 通过使用=> $rowCssClassExpression = '$data->id'; 在网格行中添加标题属性Gridview>TR>Title <table class="items"> <tbody> <tr class="odd" title="**I need to put title dynamically to each row**"> <td style=

我想为Gridview中的每一行添加标题属性。 我有什么办法可以让它工作吗

通过使用=>

$rowCssClassExpression = '$data->id';
在网格行中添加标题属性Gridview>TR>Title

<table class="items">
<tbody>
<tr class="odd" title="**I need to put title dynamically to each row**">
<td style="width:18%;line-height:2em;">
<td style="width:22%;">Jay </td>
<td style="width:15%;">Sonet Systems</td>
<td style="width:10%;">98012269</td>
<td style="width:15%;">Moderate Risk</td>
<td style="width:20%;">Suicide Call Back Service</td>
</tr>
<tr class="even">
<td style="width:18%;line-height:2em;">
<td style="width:22%;"> </td>
<td style="width:15%;">Susan Rosenthal</td>
<td style="width:10%;"> </td>
<td style="width:15%;">Moderate Risk</td>
<td style="width:20%;">Suicide Line</td>
</tr>

杰伊
Sonet系统
98012269
中等风险
自杀式回拨服务
苏珊·罗森塔尔
中等风险
自杀线

您必须覆盖类
CDATA列

下面是一个如何做的示例,我从中获得了这段代码

/**
 * DataColumn class file.
 * Extends {@link CDataColumn}
 */
class DataColumn extends CDataColumn
{
    /**
     * @var boolean whether the htmlOptions values should be evaluated. 
     */
    public $evaluateHtmlOptions = false;

     /**
     * Renders a data cell.
     * @param integer $row the row number (zero-based)
     * Overrides the method 'renderDataCell()' of the abstract class CGridColumn
     */
    public function renderDataCell($row)
    {
            $data=$this->grid->dataProvider->data[$row];
            if($this->evaluateHtmlOptions) {
                foreach($this->htmlOptions as $key=>$value) {
                    $options[$key] = $this->evaluateExpression($value,array('row'=>$row,'data'=>$data));
                }
            }
            else $options=$this->htmlOptions;
            if($this->cssClassExpression!==null)
            {
                    $class=$this->evaluateExpression($this->cssClassExpression,array('row'=>$row,'data'=>$data));
                    if(isset($options['class']))
                            $options['class'].=' '.$class;
                    else
                            $options['class']=$class;
            }
            echo CHtml::openTag('td',$options);
            $this->renderDataCellContent($row,$data);
            echo '</td>';
    }
}
$this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'article-grid',
    'dataProvider'=>$model->search(),
    'filter'=>$model,
    'columns'=>array(
        'id',
        'title',
        array(
            'class'=>'DataColumn',
            'name'=>'name',
            'evaluateHtmlOptions'=>true,
            'htmlOptions'=>array('title'=>'{$data->name}'),
        ),
        array(
            'class'=>'CButtonColumn',
        ),
    ),
));