flaviovs / yii2-composite-dataprovider
Composite data provider for Yii2
Installs: 1 304
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- php: >=8.2.0
Requires (Dev)
- codeception/codeception: ^5.0
- codeception/module-asserts: ^3.0
- codeception/module-yii2: ^1.1
- yiisoft/yii2: ^2.0
This package is auto-updated.
Last update: 2024-10-30 01:42:44 UTC
README
Composite Data Provider (CDP) is a yii\data\DataProviderInterface implementation that allows you to compose and browser several standard Yii2 data providers as if they were just one.
CDP takes care of properly paginating source data providers, so you can use any combination of pagination (or no pagination) on them -- CDPs will always paginate using the composite pagination configuration (if any).
Installation
composer require flaviovs/yii2-composite-dataprovider
Usage
$cdp = new \fv\yii\data\CompositeDataProvider([ 'dataProviders' => [ // A \yii\data\DataProviderInterface instance. $data_provider1, // Object configuration is also supported. [ 'class' => \yii\data\ActiveDataProvider::class, 'query' => $my_model->find(); ], ], ]);
CDPs also acceps a pagination
property that works the same as in
regular Yii2 data providers.
Additionally, you can use the addDataProvider($value)
to add new
data providers to a CDP.
Important
-
CDPs cannot be sorted. Of course, source data providers can be sorted normally.
-
Models and keys returned by CDPs come straight from the source data providers. That means that your data provider consumer (for example,
GridView
column configuration) must be prepared to handle models of varied type in case your source data providers return different models.
Issues
Visit http://github.com/flaviovs/yii2-composite-dataprovider