Alphapager advanced

Total 15 items.
#Last NameFirst NameBornDied
1JacksonSamuel L.1948/12/21
2JaggerMick1943/07/26
3JancsóMiklós1921/09/272014/01/31
4JansenTheo1948/03/14
5JarrettKeith1945/05/08
6JarryAlfred1873/09/081907/11/01
7JobsSteve1955/02/142011/10/05
8JohnDr.1941/11/202019/06/06
9JohnGottfried1942/08/292014/09/01
10JonesBrian1942/02/281969/07/03
11JonesGrace1948/05/19
12JonesTerry1942/02/012020/01/21
13JonesTom1940/06/07
14JoplinJanis1943/01/191970/10/04
15JoyceJames1882/02/021941/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.