简体   繁体   English

在yii2中将过滤器与CGridView和CArrayDataProvider一起使用

[英]Using filters with CGridView and CArrayDataProvider in yii2

previous i was Using filters with CGridView and CArrayDataProvider in yii 1.1 and this site helped http://www.yiiframework.com/wiki/232/using-filters-with-cgridview-and-carraydataprovider/ of late i have wanted to replicate the same view in yii2 but i have failed. 之前我曾在yii 1.1中使用带有CGridView和CArrayDataProvider的过滤器,最近该站点帮助http://www.yiiframework.com/wiki/232/using-filters-with-cgridview-and-carraydataprovider/最近我想复制yii2中的相同视图,但我失败了。 below is a sample of the code i would to resolve in yii 2. Or can anyone help with a similar alternative in yii 2 以下是我要在yii 2中解析的代码示例。或者有人可以在yii 2中提供类似的替代方法吗?

<?php
//get outgoing calls
                $outcalls = $model->getOutCalls();
                // For filtering grid
                $filtersForm = new GridForm ();
                // Get filtered data
                $filteredData = $filtersForm->filter ( $outcalls );

                $outDataProvider = new ArrayDataProvider ( $filteredData, [ // Define pagination
                            'pagination' => [
                                    'pageSize' => 10000 
                            ]
                    ] );

In Yii2 it's common practice to use a search model for the purposes of filtering. 在Yii2中,通常将搜索模型用于过滤目的。

http://www.yiiframework.com/wiki/653/displaying-sorting-and-filtering-model-relations-on-a-gridview/ http://www.yiiframework.com/wiki/653/displaying-sorting-and-filtering-model-relations-on-a-gridview/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM