【问题标题】:pagination buttons limits in yii2yii2中的分页按钮限制
【发布时间】:2016-03-04 19:06:26
【问题描述】:

我需要在我的 gridview 分页中只显示 3 个元素,然后在按钮分页中显示 3 个按钮,但按钮会动态变化。

按钮分页示例:

[1]-2-3...

点击第二个元素

[2]-3-4...

我的代码:

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

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

谢谢!!

【问题讨论】:

    标签: php button pagination yii2 limit


    【解决方案1】:

    您可以在 gridview 中使用 pager 属性来执行此操作

         <?= 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
            ],
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-11
      • 1970-01-01
      • 1970-01-01
      • 2014-08-14
      • 1970-01-01
      • 1970-01-01
      • 2021-06-03
      • 1970-01-01
      相关资源
      最近更新 更多