Alphapager demo
Showing 1-3 of 3 items.
# | Last Name | First Name | Born | Died |
---|---|---|---|---|
1 | !Xobile | 1970/09/29 | — | |
2 | 007 | 1908/05/28 | 1964/08/12 | |
3 | 50 Cent | 1975/06/06 | — |
Yii2 Alphapager lets you do alphabetic paging in the Yii framework 2.0. On this page it is shown in it's default operation, 'out of the box'.
The relevant code involved is something like this:
<?php use sjaakp\alphapager\ActiveDataProvider; use sjaakp\alphapager\AlphaPager; $query = Person::find()->orderBy('last_name, first_name'); $dataProvider = new ActiveDataProvider([ 'query' => $query, 'alphaAttribute' => 'last_name', ]); ?> <?= AlphaPager::widget([ 'dataProvider' => $dataProvider, ]) ?> <?= GridView::widget([ 'dataProvider' => $dataProvider, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], 'last_name:ntext', 'first_name:ntext', 'born:date', 'died:date', ], ]); ?>
A slightly more advanced example is here.