I need in my gridview pagination there show only 3 elements and then in the button pagination show 3 buttons but the button change dynamically.
example buttons pagination:
[1]-2-3...
click in second element
[2]-3-4...
my code:
public function search($params)
{
$query = Area::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSize' => 3,
],
]);
Thanks !!
You can do this in gridview with the pager
attribute
<?= 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'],
..........
this are the option available for pager
'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
],
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With