Alphapager advanced
Total 18 items.
# | Last Name | First Name | Born | Died |
---|---|---|---|---|
1 | Eastwood | Clint | 1930/05/31 | — |
2 | Eco | Umberto | 1932/01/05 | 2016/02/19 |
3 | Edison | Thomas Alva | 1847/02/11 | 1931/10/18 |
4 | Einstein | Albert | 1879/03/14 | 1955/04/18 |
5 | Elliot | Cass | 1941/09/19 | 1974/07/29 |
6 | Ellis | Bret Easton | 1964/03/07 | — |
7 | Ellroy | James | 1948/03/04 | — |
8 | Emerson | Keith | 1944/11/02 | 2016/03/11 |
9 | Emmanuel | Tommy | 1955/05/31 | — |
10 | Eno | Brian | 1948/05/15 | — |
11 | Enzensberger | Hans Magnus | 1929/11/11 | — |
12 | Erasmus | Desiderius | 1466/10/18 | 1536/07/02 |
13 | Escher | M.C. | 1898/06/17 | 1972/03/27 |
14 | Euler | Leonhard | 1707/04/15 | 1783/09/18 |
15 | Eustache | Jean | 1938/03/17 | 1981/11/04 |
16 | Euwe | Max | 1901/05/20 | 1981/11/27 |
17 | Everly | Don | 1937/02/01 | 2021/08/21 |
18 | Everly | Phil | 1939/01/19 | 2014/01/03 |
Yii2 Alphapager lets you do alphabetic paging in the Yii framework 2.0. On this page it is shown with some special settings.
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', 'alphaDigits' => 'compact', // one button for digits '0' - '9' 'alphaPages' => [ 'P' => [ 'label' => 'pq', // label button 'P' with 'pq' 'pattern' => [ '[PpQq]' ], // regular expression: include words starting with 'Q' under 'P' ], 'Q' => false, // suppress page 'Q' 'Z' => [ 'label' => 'x-z', // label button 'Z' with 'x-z' 'pattern' => [ '[X-Zx-z]' ], // regular expression: include words starting with 'X' or 'Y' under 'Z' ], 'X' => false, // suppress page 'X' 'Y' => false, // suppress page 'Y' ], 'pagination' => false // switch off normal pagination ]); ?> <?= AlphaPager::widget([ 'dataProvider' => $dataProvider, 'preButtons' => [], // no 'all' button 'lowerCase' => true // buttons in lower case ]) ?> <?= GridView::widget([ 'dataProvider' => $dataProvider, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], 'last_name:ntext', 'first_name:ntext', 'born:date', 'died:date', ], ]); ?>
A basic example is here.