Php yii2中的分页按钮限制

Php yii2中的分页按钮限制,php,button,pagination,yii2,limit,Php,Button,Pagination,Yii2,Limit,我需要在gridview分页中只显示3个元素,然后在按钮分页中显示3个按钮,但按钮会动态更改 分页按钮示例: [1]-2-3... 单击第二个元素 [2]-3-4... 我的代码: 公共函数搜索($params) { $query=Area::find(); $dataProvider=新的ActiveDataProvider([ 'query'=>$query, “分页”=>[ “页面大小”=>3, ], ]); 谢谢!!您可以在gridview中使用pager属性执行此操作

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

分页按钮示例:

[1]-2-3...
单击第二个元素

[2]-3-4...
我的代码:

公共函数搜索($params)
{
$query=Area::find();
$dataProvider=新的ActiveDataProvider([
'query'=>$query,
“分页”=>[
“页面大小”=>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
        ],