Hi, thanks for reply. I tried -
$model = new Whisky;
$this->renderPartial('distillery_index',array('model'=>$model),false,true);
but didn’t worked.
My view page contains the data from different models, and having 2 cGridView from different models. So i mentioned $model in view itself just before the cGridView -
$model = new Whisky();
$dataProvider = $model->dashboard_whisky_list($records);
$this->widget('CGridViewPlus', array(
'id' => 'whisky-grid',
'dataProvider' => $dataProvider,
'template'=>"{pager}\n{items}\n{pager}",
'updateSelector'=>'whisky-selector', //update selector
'columns' => array(
array(
'class' => 'CButtonColumn',
'template' => '{update} {delete}',
'buttons'=>array(
'update' => array
(
'url'=>'Yii::app()->createUrl("whisky/update", array("id"=>$data->distilldId))',
),
),
'afterDelete' => 'function(link,success,data){ if(success) alert("Whisky deleted successfuly"); }',
),
),
'beforeAjaxUpdate' => 'js:function(id) {showLoader();}',
'afterAjaxUpdate' => 'js:function(id, data) {hideLoader();}',
));
In above code, ‘CGridViewPlus’ is extended class for ‘CGridView’.
And in the model -
static function dashboard_whisky_list($search)
{
$criteria = new CDbCriteria;
$criteria->alias = 'w';
$criteria->select = array('w.whiskyId as whiskyId', 'w.distilldWhiskyId as distilldId', 'w.whiskyName as name', 'wc.categoryName as category', 'w.whiskyDescription', 'w.abv', 'w.age', 'w.avgRating', 'd.distilleryName as distillery', 'CASE WHEN ISNULL(r.regionName) THEN c.countryName ELSE CONCAT(r.regionName,", ",c.countryName) END as location, w.labelUrl as label, t.type as type, w.active, w.verified, (select COUNT(*) from reviews_stats as uw where uw.whiskyId = w.distilldWhiskyId) as checkin_count, (select ROUND(AVG(r.rating),1) from reviews as r JOIN reviews_stats as uw ON (r.userWhiskyId = uw.userWhiskyId) where r.rating <> 0 and uw.whiskyId = w.distilldWhiskyId) as avg_rating');
$criteria->join =' LEFT JOIN whisky_category as wc ON w.categoryId=wc.categoryId';
$criteria->join .=' LEFT JOIN whisky_distilleries as d ON w.distilleryId=d.distilldDistilleryId';
$criteria->join .=' LEFT JOIN regions as r ON w.regionId=r.regionId';
$criteria->join .=' LEFT JOIN countries as c ON w.countryId=c.countryId';
$criteria->join .=' LEFT JOIN whisky_type as t ON w.typeId=t.typeId';
$sort = new CSort();
$sort->attributes = array(
'name'=>array(
'asc'=>'name ASC',
'desc'=>'name DESC',
),
'checkin_count'=>array(
'asc'=>'checkin_count ASC',
'desc'=>'checkin_count DESC',
),
'avg_rating'=>array(
'asc'=>'avg_rating ASC',
'desc'=>'avg_rating DESC',
),
'*', // this adds all of the other columns as sortable
);
$criteria->addcondition("w.active = 'Y'");
$criteria->addcondition("w.distilleryId = ".Yii::app()->user->referenceid);
return new CActiveDataProvider('Whisky', array(
'pagination'=>array(
'pageSize'=> Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']),
'currentPage' => Yii::app()->user->getState('Whiskypage', 0),
),
'criteria' => $criteria,
'sort'=>$sort,
'pagination'=>array(
'pageVar'=>'whisky-selector', //page selector
),
));
}
I have attached the image for my layout.
Will that help you to find root cause ?