在kartik-v / yii2-grid Kartik Gridview中禁用分页

时间:2016-03-07 11:34:09

标签: yii2

如何在Kartik Gridview中禁用分页? 我正在使用下面的代码

    echo GridView::widget([
        'dataProvider'=>$dataProvider,
        'filterModel'=>$searchModel,
        'showPageSummary'=>true,
            'responsive'=>true,

            'hover' => true,
         'pjax'=>true,
            'containerOptions'=>['style'=>'overflow: auto'], // only set when $responsive = false
            'headerRowOptions'=>['class'=>'kartik-sheet-style'],
            'filterRowOptions'=>['class'=>'kartik-sheet-style'],

        'striped'=>true,
        'hover'=>true,
            '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
            ],      
        'panel'=>['type'=>'primary', 'heading'=>'Select Option to Publish Policy'],
        'columns'=>[
            ['class'=>'kartik\grid\SerialColumn'],
 ['class' => 'kartik\grid\CheckboxColumn',
             'rowSelectedClass' => GridView::TYPE_INFO,
                 'name' => 'id',
                'contentOptions' => function ($model, $key, $index, $column){//print_r($model); 
                return  ['username'=>$model->username];
        },
        'checkboxOptions' => function ($model, $key, $index, $column)  {

            return ['key' => $model->username, 'value' => $model->username];
            },
        ], 

    ],
]);

我尝试将pageSizepagination添加到false,但没有效果。

1 个答案:

答案 0 :(得分:5)

没有分页意味着显示所有实例然后您可以设置pageSize = 0

       $dataProvider->pagination->pageSize=0;

或者您可以使用

       $dataProvider->pagination  = false;