How to call GridView with parameter for searchmodel?

Hi guys, in my Controller, I have following public method


    public function actionIndex($searchparam = NULL) {        if (isset($_SESSION['fk'])) {            unset($_SESSION['fk']);        }        if (isset($_SESSION['adressen'])) {            unset($_SESSION['adressen']);        }        if (isset($_SESSION['name'])) {            unset($_SESSION['name']);        }        if (isset($_SESSION['geschlecht'])) {            unset($_SESSION['geschlecht']);        }        $searchModel = new MailAusgangSearch();        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);        return $this->render('index', [                    'searchModel' => $searchModel,                    'dataProvider' => $dataProvider,        ]);    }

I want to call this method by another module,which will send, repsectively give any parameter. Apending from this given parameter, GridView should show display records, selected by searchmodel.For instance, I call method like this:


    [        'class' => 'yii\grid\ActionColumn',        'template' => '{mail_index}',        'buttons' => [            'mail_index' => function ($model, $id) {                return Html::a('<span class="glyphicon glyphicon-paperclip"></span>', ['/mail/mail-eingang/index', 'id' => $model->id_person], ['title' => 'Mail anzeigen', 'data' => ['pjax' => '0']]);            },        ],    ],

Now, GridView of mail/mail-eingang/index should display records depending on id_person.Any ideas how to call searchmodel with parameter given by another module?

Got it by my own:All i had to do is to implement follwong code in searchmodel:




public function search($params, $fk = NULL) {


 if ($fk != NULL) {

            $query = MailAusgang::find()->where(['id_person_mitarbeiter' => $fk]);

        } else {

            $query = MailAusgang::find();

        }

.

.

.



In Conroller, i hat to define dataProvider like this:




$dataProvider = $searchModel->search(Yii::$app->request->queryParams, $fk);



Et voila, records will be selected by parameter given of another module like this:




<?= Html::a(Yii::t('app', 'verschickte Mails anzeigen'), ['/mail/mail-ausgang/index', 'fk' => 2], ['class' => 'btn btn-primary', 'title' => 'zum Maileingangmodul', 'data' => ['pjax' => '0']]) ?>