Add extra button - filters


I am trying to place 4 buttons, above a Yii2 GridView, in order to display, different grid results according to triggered button value.

So, the question is, how to implement, such a functionality?

Any ideas are much appreciated.

Thank you

Define the controller action as below. In the below example, I use the index action and 4 options (for the 4 buttons) ‘a’, ‘u’, ‘c’ and ‘d’. Based on what parameter is sent - with the default being ‘a’, take the appropriate flow.

    public function actionIndex($fn='a')
        $fns = ['a', 'u', 'c', 'd'];
        if (!in_array($fn, $fns))
            return $this->redirect(['/homepage']);

        // Add switch statement to do different things, query different tables, etc.

        return $this->render('index', [
            'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,
            'fn' => $fn,

Pass the $fn back to the view so the view can also display appropriately based on what button was clicked. For e.g. disable the button that was clicked so only the other 3 are enabled.