AleCat83
(Alessandro Cattaneo83)
1
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:
-
general list with all documents
-
specialized list with only "category 1" documents
-
specialized list with only "category 1" documents
4)…
What’s the best method to accomplish this?
Thank you
Ale
melicerte
(Recycling Spam)
2
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 https://github.com/yiisoft/yii2/issues/5668 and http://stackoverflow.com/questions/21992687/php-yii2-gridview-filtering-on-relational-value and this http://www.ramirezcobos.com/2014/04/16/displaying-sorting-and-filtering-model-relations-on-a-gridview-yii2/
and then try to find what is the best approach for you.
korshak
(Dkorshak)
3
$searchModel = new YourModelSearch([
'balance' => 100,
'category_id' => 200,
]);