我在 CGridView 中使用的代码在列值的 $data->gen_id 和 $data->erc_gen 中为我提供了一个空值,当我使用浏览器检查器进行检查时,它给了我<a href="/ekportal/erc/index.php?r=ercGen/update&id="></a>
ercgen/admin 代码如下:
$qryTmp =
"SELECT gen_id, erc_ref,B.complete_name sales_executive,C.description type,D.client_name client_id,event_name, E.status_desc erc_status ".
"FROM erc_gen A, Users B, erc_type C, clients D, erc_status E ".
"WHERE A.sales_executive = b.user_id ".
"AND A.type = C.typ_no ".
"AND A.client_id = D.client_id ".
"AND A.erc_status = E.id ".
"AND sales_executive = '$user_id' ".
"AND erc_status = '1' ";
$count = Yii::app()->db->createCommand('SELECT COUNT(*) FROM ('.$qryTmp.') X')->queryScalar();
$dataProvider=new CSqlDataProvider($qryTmp, array(
'totalItemCount'=>$count,
'sort'=>array(
'attributes'=>array(
'gen_id','erc_ref', 'sales_executive', 'type','client_id','event_name','erc_status'
),
),
'pagination'=>array(
'pageSize'=>10,
),
));
//CGRIDVIEW
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'pager'=>array(
'header'=>'',
'firstPageLabel'=>'<<',
'prevPageLabel'=>'<',
'nextPageLabel'=>'>',
'lastPageLabel'=>'>>',
),
'columns'=>array(
array(
'header'=>'#',
'value'=>'$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)',
),
array(
'header'=>'Reference Number',
'name'=>'erc_ref',
'type'=>'raw',
'value'=>'CHtml::link($data->erc_ref,Yii::app()->createUrl("ercGen/update",array("id"=>"$data->gen_id")))',
),