long399/yii2-widget-advanced-linkpager

yii2 advanced LinkPager Widget

0.1.0 2021-08-11 04:17 UTC

This package is auto-updated.

Last update: 2024-05-17 11:39:57 UTC


README

Total Downloads License

AdvancedLinkPager widget for Yii Framework 2.0

Screenshot

Installation

The preferred way to install this extension is through composer. Either run

 composer require --prefer-dist long399/yii2-widget-advanced-linkpager

or add

"long399/yii2-widget-advanced-linkpager": "~0.1"

to the require section of your composer.json file.

Usage

view:

echo GridView::widget([
  ...
  'pager' => [
    'class' => AdvancedLinkPager::class,
    'options' => ['class' => 'pagination'],
    'firstPageLabel' => 'начало',
    'lastPageLabel' => 'конец',
    'hideOnSinglePage' => false,

    'template' => '{pageButtons}{pageList}{pageSize}{pageJump}',
    'pageListLabel' => 'Страница',
    'pageListCssClass' => 'btn btn-warning dropdown-toggle',
    'pageSizeLabel' => 'Размер',
    'pageSizeCssClass' => 'btn btn-primary dropdown-toggle',
    'pageSizeItems' => [1, 10, 25, 50, 100],
  ],
  ...
]);

searchModel:

public function search($params)
{
  ...
  $pageSize = isset($params['per-page']) ? intval($params['per-page']) : 10;
  $dataProvider = new ActiveDataProvider([
    'query' => $query,
      'pagination' =>  [
        'pageSize' => $pageSize
      ],
  ]);
  ...
}

Author

long399, e-mail: long399@mail.ru