Alphapager advanced
Total 25 items.
# | Last Name | First Name | Born | Died |
---|---|---|---|---|
1 | Kafka | Franz | 1883/07/03 | 1924/06/03 |
2 | Kakehashi | Ikutaro | 1930/02/07 | 2017/04/01 |
3 | Kamerlingh Onnes | Heike | 1853/09/21 | 1926/02/21 |
4 | Kandinsky | Wassily | 1866/12/16 | 1944/12/13 |
5 | Kant | Immanuel | 1724/04/22 | 1804/02/12 |
6 | Karina | Anna | 1940/09/22 | 2019/12/14 |
7 | Karsh | Yousuf | 1908/12/03 | 2002/07/13 |
8 | Keaton | Buster | 1895/10/04 | 1966/02/01 |
9 | Keitel | Harvey | 1939/05/13 | — |
10 | Kennedy | John F. | 1917/05/29 | 1963/11/22 |
11 | Kepler | Johannes | 1571/12/17 | 1630/11/15 |
12 | Kerouac | Jack | 1922/03/12 | 1969/10/21 |
13 | Kiefer | Anselm | 1945/03/08 | — |
14 | Kilmister | Lemmy | 1945/12/24 | 2015/12/28 |
15 | King | B.B. | 1925/09/16 | 2015/05/14 |
16 | King | Ben E. | 1938/09/28 | 2015/04/30 |
17 | Kinski | Klaus | 1926/10/18 | 1991/11/23 |
18 | Klee | Paul | 1879/12/18 | 1942/06/29 |
19 | Knuth | Donald | 1938/01/10 | — |
20 | Koestler | Arthur | 1905/09/05 | 1983/03/03 |
21 | Koolhaas | Rem | 1944/11/17 | — |
22 | Kooning | Willem de | 1904/04/24 | 1997/03/19 |
23 | Koons | Jeff | 1955/01/21 | — |
24 | Kravitz | Lennie | 1964/05/26 | — |
25 | Kubrick | Stanley | 1928/07/26 | 1999/03/07 |
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.