Reputation: 391
I'm using Yii Bootstrap TbGridView to show a DataProvider from CSqlDataProvider. However, I can't display the value out to the screen. I don't know what happened. Here is my code:
Controller page:
$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,
));
Prospect View page:
$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'
),
));
I do the testing on the local server, there is no error, but the value that is looped by using:
array('name'=>'Prospect Date', 'type'=>'raw', 'value'=>$data->ProspectDate),
the value for this column is not diplayed. However, the column for 'Consultant', the value can be displayed. Another problem is when I uploaded the file into real server, error is given:
Undefined variable: data
where the data, refers to the $data->ProspectDate Can someone help me to figure it out, what is the problem?
Upvotes: 0
Views: 133