Alphapager advanced
Total 16 items.
| # | Last Name | First Name | Born | Died |
|---|---|---|---|---|
| 1 | Jackson | Samuel L. | 1948/12/21 | — |
| 2 | Jagger | Mick | 1943/07/26 | — |
| 3 | Jancsó | Miklós | 1921/09/26 | 2014/01/31 |
| 4 | Jansen | Theo | 1948/03/14 | — |
| 5 | Jarrett | Keith | 1945/05/08 | — |
| 6 | Jarry | Alfred | 1873/09/08 | 1907/11/01 |
| 7 | Jobs | Steve | 1955/02/14 | 2011/10/05 |
| 8 | John | Dr. | 1941/11/20 | 2019/06/06 |
| 9 | John | Gottfried | 1942/08/29 | 2014/09/01 |
| 10 | Jones | Brian | 1942/02/28 | 1969/07/03 |
| 11 | Jones | Grace | 1948/05/19 | — |
| 12 | Jones | Quincy | 1933/03/14 | 2024/11/03 |
| 13 | Jones | Terry | 1942/02/01 | 2020/01/21 |
| 14 | Jones | Tom | 1940/06/07 | — |
| 15 | Joplin | Janis | 1943/01/19 | 1970/10/04 |
| 16 | Joyce | James | 1882/02/02 | 1941/01/13 |
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.