pre filtered index action

Hello everyone,

I’ve got a index action that render a gridView to show a list of documents. Each document has a filtrable “category” column.

I need to create different pages that show the pre-filtered index action with the category filter applied.

In example I need to create:

  1. general list with all documents

  2. specialized list with only "category 1" documents

  3. specialized list with only "category 1" documents


What’s the best method to accomplish this?

Thank you


You need default value for your category filter. And, as far as I can tell, there is no offcial way to set default value for filters in yii2.

You might be interested by reading this and and this

and then try to find what is the best approach for you.


$searchModel = new YourModelSearch([

   'balance' => 100,

   'category_id' => 200,


Thank you guys! :)