-
Book Overview & Buying
-
Table Of Contents
Yii2 By Example
By :
GridView is the widget provided by Yii2 to display data in a grid layout.
This widget requires that data used as an input source is an extension of the abstract class yii\data\BaseDataProvider.
To deal with a data source, DataProvider supplies some additional actions to handle pagination and sorting.
BaseDataProvider has a method named getModels() that returns a list of items for the current page. This means that we could also use DataProvider to paginate data from a source and display it as we need to.
By default, the framework has three core classes that extend yii\data\BaseDataProvider:
yii\data\ActiveDataProvider
yii\data\ArrayDataProvider
yii\data\SqlDataProvider
The first one, ActiveDataProvider, uses a yii\db\Query instance from ActiveRecord as a data source. The parameter array is passed to the constructor and the yii\db\Query object is filled out in the query attribute:
// build an ActiveDataProvider with an empty query and a pagination with 35 items for page...
Change the font size
Change margin width
Change background colour