-1

i have model from "feedbackmodel" :

public function search($params)
{
    $query = Feedback::find();

    $dataProvider = new ActiveDataProvider([
        'query' => $query,
        'sort'=> ['defaultOrder' => ['TANGGAL'=>SORT_DESC]],
        'pagination' => array('pageSize' => 10),
    ]);

    $this->load($params);

    if (!$this->validate()) {
        // uncomment the following line if you do not want to return any records when validation fails
        // $query->where('0=1');
        return $dataProvider;
    }

    $query->andFilterWhere([
        'ID_KOMENTAR' => $this->ID_KOMENTAR,
        'id' => $this->id,
        'TANGGAL' => $this->TANGGAL,
    ]);

    $query->andFilterWhere(['like', 'KOMENTAR', $this->KOMENTAR]);

    return $dataProvider;
}

and the gridview code like this:

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'layout'=>"{items}",
    'tableOptions' => ['class' => 'table  table-bordered table-hover'],
    'showFooter'=>false,
    'showHeader' => false,
    'pager' => [
            'firstPageLabel' => 'First',
            'lastPageLabel' => 'Last',
        ],

    'columns' => [
        [   'attribute' => 'iduser.photo',
            'format' => 'html',
            'value'=>  function($data) { return Html::img($data->imageurl) . " <p class='feedback-username'>" . $data->username . "</p>"; },
            'contentOptions'=>['style'=>'max-width: 10px; max-height: 10px'],
        ],

        [   'attribute' => 'KOMENTAR',
            'format' => 'raw',
            'value' => function($model) { return $model->KOMENTAR  ."<br><p class='feedback-date'>". $model->TANGGAL ."</p>";},
        ],

        [   'class' => 'yii\grid\ActionColumn',
            'contentOptions'=>['style'=>'width: 5px;'],
            'template' => '{update} {delete}'
        ],
    ],
]); ?>

But why the page button is not shown, its limited but i can see the other data bcos the i cant find the button next or prev to the other page

1 Answers1

0

I test your code

if I remove the layout=>"{items}", the page buttons are show otherwise not (i think your layout assignment mean show only the item and not the pager) try simply comment it

<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
//'layout'=>"{items}",
'tableOptions' => ['class' => 'table  table-bordered table-hover'],
'showFooter'=>false,
'showHeader' => false,
'pager' => [
        'firstPageLabel' => 'First',
        'lastPageLabel' => 'Last',
    ],
  ..........
scaisEdge
  • 124,973
  • 10
  • 73
  • 87