I am facing issue with a scenario that I have to show data in two different grids present on same view. I don't want to query separately for both grids. What I want to achieve is to query only once and split data for both grids separately and pass it to both grids. I have the option to hide rows on type basis but I don't want to use this
I have tried the option to hide rows on type basis but I don't want to use this option. I want something to split the main data provider into two data providers
The only way to do that with
yii\data\ActiveDataProvideris extending it and overriding itsprepareModels()andprepareKeys()methods.Other option is to use
yii\data\ArrayDataProviderinstead.The main disadvantage of using
ArrayDataProvideris, that you have to load all models into array even if you plan to use pagination. So if there are many rows in your table, it might be better to use two independentActiveDataProviderand let them load the data in two queries.