CGridView paging not working

I have a model which have query with join in CDbCriteria like this

public function cpu($filter)


	$criteria = new CDbCriteria;

	$criteria->alias = 'op';

	$criteria->select = "op.*, oc.trainingtype_c";

	$criteria->join = 'join opportunities_cstm oc on ';

	$criteria->join .= 'join users u on ';

	$criteria->condition = "u.deleted=0 and op.deleted=0 and not op.assigned_user_id is null ";

	$criteria->order = 'op.assigned_user_id, oc.expectdate_c';


	if ($filter['department']!='Nasional') {

		if ($filter['department']=='DKI (All)') 

			$criteria->condition .= "and u.department like 'DKI%'";

		else if ($filter['department']=='NDD (All)') 

			$criteria->condition .= "and u.department like 'NDD%'";


			$criteria->condition .= "and u.department like '".$filter['department']."'";


	if ($filter['training_type']!='Semua') {

		$criteria->condition .= "and oc.trainingtype_c like '".$filter['training_type']."'";


	if ($filter['account_name']!='') {

		$criteria->condition .= "and in ( select opportunity_id 

			from accounts t1 join accounts_opportunities t2 on

			where like '%".trim($filter['account_name'])."%' )";


	return new CActiveDataProvider(get_class($this), array(



			'pageSize'=> Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']),




and a view to render it like this,

$this->widget('zii.widgets.grid.CGridView', array(






it’s working fin for first page, but gives empty data for second and other pages.

did I miss something?



in CGridView

Paging in CGridView use Ajax, and $filter variable not include in so

use property AfterAjaxUpdate for update $filter variable

you can read manual CGridView, how to user AfterAjaxUpdate

This link is example how to use AfterAjaxUpdate, this solve myproblem

thanks for your reply.

$filter is actually a model, and i cant find a way to pass it as argument using to "cpu" function using javascript

I solved it using session.

hello can u share to us how to fix it, because I have problem same, cgridview in page 1 work, but while I click page 2 etc… it doesn’t work, and I use in jdialog