簡體   English   中英

yii2中的分頁按鈕限制

[英]pagination buttons limits in yii2

我需要在gridview分頁中只顯示3個元素,然后在按鈕分頁中顯示3個按鈕,但按鈕動態變化。

示例按鈕分頁:

[1]-2-3...

單擊第二個元素

[2]-3-4...

我的代碼:

public function search($params)
{
    $query = Area::find();

    $dataProvider = new ActiveDataProvider([
        'query' => $query,
        'pagination' => [
            'pageSize' => 3,
        ],
    ]);

謝謝 !!

您可以使用pager屬性在gridview中執行此操作

     <?= GridView::widget([
    'dataProvider' => $dataProvider,
    'summaryOptions' => ['class' =>'dfenx_pagination_summary',],
    'pager' => ['options' => ['class' => 'pagination pull-right']],
    'filterModel' => $searchModel,
    'pager' => [
        'maxButtonCount'=>3,    // Set maximum number of page buttons that can be displayed
        ],
    'columns' => [
        ['class' => 'yii\grid\SerialColumn'],
      ..........

這是尋呼機可用的選項

    'pager' => [
        'options'=>['class'=>'pagination'],   // set clas name used in ui list of pagination
        'prevPageLabel' => 'Previous',   // Set the label for the "previous" page button
        'nextPageLabel' => 'Next',   // Set the label for the "next" page button
        'firstPageLabel'=>'First',   // Set the label for the "first" page button
        'lastPageLabel'=>'Last',    // Set the label for the "last" page button
        'nextPageCssClass'=>'next',    // Set CSS class for the "next" page button
        'prevPageCssClass'=>'prev',    // Set CSS class for the "previous" page button
        'firstPageCssClass'=>'first',    // Set CSS class for the "first" page button
        'lastPageCssClass'=>'last',    // Set CSS class for the "last" page button
        'maxButtonCount'=>10,    // Set maximum number of page buttons that can be displayed
        ],

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM