2016-03-07 40 views
1

如何在Kartik Gridview中禁用分頁功能? 我使用類似下面在kartik-v/yii2-grid中禁用分頁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]; 
      }, 
     ], 

    ], 
]); 

我嘗試添加pageSizepaginationfalse的代碼,但沒有工作。

回答

5

無分頁意味着顯示所有的實例,然後你可以設置的pageSize = 0

 $dataProvider->pagination->pageSize=0; 

,或者您可以使用

 $dataProvider->pagination = false;