user7282
user7282

Reputation: 5196

Disable pagination in kartik-v/yii2-grid Kartik Gridview

How the pagination can be disabled in Kartik Gridview? I am using the code like below

    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];
            },
        ], 

    ],
]);

I tried adding pageSize and pagination to false, but didnt work.

Upvotes: 3

Views: 9005

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133360

No pagination mean show all the instance then you can set pageSize = 0

       $dataProvider->pagination->pageSize=0;

or you can use

       $dataProvider->pagination  = false;

Upvotes: 5

Related Questions