0

我正在使用 Yii Bootstrap TbGridView 来显示来自 CSqlDataProvider 的 DataProvider。但是,我无法将值显示到屏幕上。我不知道发生了什么。这是我的代码:

控制器页面:

$model = new ReportOptionForm('search');

$sql = 'SELECT c.client_id as "ProspectID", c.name as "ProspectName", count(t.activity_id) as "CallCount", c.created_on as "ProspectDate", con.name as "Consultant"';
$sql .= ' FROM clients c LEFT OUTER JOIN consultants con ON c.CIC = con.con_id LEFT OUTER JOIN client_activities t ON c.client_id = t.client_id';
$sql .= ' WHERE c.status = '.Client::TYPE_PROSPECT;

if(!($con_id == ''))
{
    $sql .= ' AND c.CIC ='. $con_num;
}

if(!($team == ''))
{
    $sql_count .= ' AND con.tm_id = '.$team;    
}

if (!($startTs == NULL) && !($endTs == NULL)) {
    $sql .= ' AND DATE(c.created_on) between "'.$startTs.'" and "'.$endTs.'"';
}               
$sql .= ' GROUP BY c.client_id';

$dataProvider = new CSqlDataProvider($sql, array(
            'totalItemCount' => 100,
            'keyField' => 'ProspectID',
            'sort' => array(
                    'defaultOrder'=>'ProspectID ASC',
            ),
            'pagination'=>array(
                    'pageSize'=>$pageSize,
            ),
        ));

$render = Yii::app()->request->isAjaxRequest ? 'renderPartial' : 'render';
$this->$render('prospect',array(
                'model'=>$model,
                'dataProvider'=>$dataProvider,
                'pageSize'=>$pageSize,
)); 

前景视图页面:

$gridWidget=$this->widget('bootstrap.widgets.TbGridView',array(
    'id'=>'report-grid',
    'dataProvider'=>$dataProvider,
    'columns'=>array(
        array(
            'name'=>'No',
            'value'=>'$row+1',
            'htmlOptions'=>array('style'=>'text-align:center'),
        ),

        array('name'=>'Prospect Date', 'type'=>'raw', 'value'=>$data->ProspectDate),
        array('name'=>'Prospect Name', 'type'=>'raw', 'value'=>$data->ProspectName),
        'Consultant'        
    ),
)); 

我在本地服务器上进行测试,没有错误,但是使用循环的值:

array('name'=>'Prospect Date', 'type'=>'raw', 'value'=>$data->ProspectDate),

此列的值未显示。但是,对于“顾问”的列,可以显示该值。另一个问题是当我将文件上传到真实服务器时,会出现错误:

Undefined variable: data

数据在哪里,指的是$data->ProspectDate 有人可以帮我弄清楚,有什么问题吗?

4

0 回答 0