php - yii2 中的分页按钮限制

标签 php button pagination yii2 limit

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

示例按钮分页:

[1]-2-3...

点击第二个元素

[2]-3-4...

我的代码:

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

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

谢谢!!

最佳答案

您可以在 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
        ],

关于php - yii2 中的分页按钮限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34010584/

相关文章:

javascript - 按钮在第一次点击时不起作用

android - 以编程方式创建的 RippleDrawable 看起来与其 xml 对应物不同

php - magento 安装错误 "PHP extension "curl“必须加载”

php - 您会考虑使用哪种系统的PHP Killer?

php - MySQL 中带有通配符或正则表达式的数值

php - 选择月份中的日期在 30 到 15 之间的所有记录

css - 交错文本和按钮的问题

javascript - 如何实现页面计数器?

mongodb - Mongoose 分页和过滤器

php - 正确使用 Laravel 的分页方法?