restlin / grid-to-session-behavior
This is yii2 controller behavior. It can save and restore grid filters, page and sort in session.
Installs: 10
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2025-01-21 15:56:42 UTC
README
This is yii2 controller behavior. It can save grid filters, page and sort in session and restore when user return to action with grid.
example for using this behavior in controller:
/** * Lists all Document models. * @param integer $mode in this case this parameter is indicator for restore params from session * @return mixed */ public function actionIndex($mode=null) { $searchModel = new DocumentSearch(); if(!$mode) { $this->loadParams(); $mode = Yii::$app->request->get('mode'); } $this->saveParams('DocumentSearch',['mode'=>1]); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); }