How can I go back to the same page in GridView after updating a particular record.
For example, when I click an update icon in the button column of a row on GridView page 5 then I get redirected to page 1 after saving the record changes.
public function actionAdmin()
{
$model=new Wage('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Wage']))
{
$model->attributes=$_GET['Wage'];
}
Yii::app()->user->setState('grid',$_GET);//saving all the get parameters into session.
$this->render('admin',array(
'model'=>$model,
));
}
views/wage/view.php.
Just append the following in view.php
if(Yii::app()->user->hasState("grid"))
{
$grid=Yii::app()->user->getState('grid');
$route=array("wage/admin");
echo CHtml::link("Return to Grid",array_merge($route,$grid));
Yii::app()->user->setState("grid",null);
}
Thank you very much, this works perfectly. I created the link at bottom of the view and it brings me back to where I came from. Now I am happy to understand a little, how yii manages sessions.
Please can you help me, how to change also the menu link back to the admin page on this view. I am a yii beginner and I have much troubles to understand the logic and the object structure of yii …
Please can you help me to change the menu item like that: