Filter Gone When Clicking Next Page In Tbgridview

I have a gridview with filters. When I filter a column, it works. But when I want to go to the next page of the result, the gridview is reset. The filter is gone. Has anybody encountered this?

can you post the code?

The code is something like this.

This is the search function in my model.





public $table1Name;

public function searchByIds($ids)

{

	$criteria = new CDbCriteria;

	$criteria->together = true;

	$criteria->with = array('table1'),

	$criteria->compare('t.id', $this->id);

	$criteria->compare('table1.name',strtoupper($this->table1Name), true, 'OR');


	$criteria->addInCondition('t.id', $ids);

	if(in_array($this->id,$ids))

		$criteria->compare('t.id', $this->id);

			

			

	return new CActiveDataProvider($this, array(

		'criteria' => $criteria,

		'pagination' => array(

                    'params' => array(),

                    'route' => '/module/controller/add',

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

        ),

	));

}

The action in controller




public function actionAdd()

{

	$entries = FirstModel::model()->findAll();

	$ids = array();

	foreach($entries as $entry){

		if(empty($entry->stock)) $ids[] = $entry->id;

		else{

			if($entry->stock->volume == '' || $entry->stock->volume == 0) $ids[] = $entry->id;

		}

	}

	

	$model = new SecondModel('searchByIds', array('id'=>$ids));

	$model->unsetAttributes;

	if(isset($_GET['SecondModel'])){

		$model->attributes = $_GET['SecondModel'];

		if(isset($_GET['SecondModel']['table1Name']))

			$model->table1Name = $_GET['SecondModel']['table1Name'];

	}

	

	$this->render('view', array(

		'model' => $model,

		'ids'=>$ids

	));


}



My tbgridview




$this->widget('bootstrap.widgets.TbExtendedGridView', array(

	'template' => "{pager}{summary}{items}{pager}",

	'dataProvider' => $model->searchByIds($ids),

	'filter'=>$model,

	'ajaxUpdate' => false

	'columns' => array(

		'id',

		array(

			'name' => 'table1Name',

			'value' => function($data){

				if(!empty($data->table1))

					return(!isset($data->table1->name) ? "N/A" : $data->table1->name);

			}

		),

	),

));




Hi,

change the line


 $this->render('view', array('model' => $model,'ids'=>$ids));

to


 $this->render('view', array('model' => $model,'ids'=>$ids),false,true);

i am not sure it’s working or not…

Didn’t work :( But thanks! :)

Hi,

you can try on admingridview and call on searchByIds function


'afterAjaxUpdate'=>'function(id,options){

		//code here..

	}',