Yii2-Grid view showing wrong count of items

廉价感情. 提交于 2019-12-11 04:51:04

问题


I have grid view in which there are 8 items. But the count is displaying Showing 1-8 of 10 items.

Controller code

public function actionViewsetpdf($id)
{
    $model = $this->findModel($id);

    $session = Yii::$app->session;
    $sqla = $session->get('result');

    $session = Yii::$app->session;
    $cnt = $session->get('count');

    $dataProvider = new SqlDataProvider([
        'sql' => $sqla,
        'totalCount'=>$cnt,
        'pagination' => [
            'pageSize' => 20,
        ],
    ]);

    return $this->render('viewsetpdf', [
        'dataProvider' => $dataProvider,
        'model' => $this->findModel($id),
        'id' => $model->id
        /*'searchModel' => $searchModel*/
    ]);


}

View Code

 <?= GridView::widget([
         'dataProvider' => $dataProvider,
          /*'filterModel' => $searchModel,*/


       'columns' => [

           ['class' => 'yii\grid\SerialColumn'],
           [
               'label'=>'OGP Serial #',
               'value' => 'OGP_Serial_No'
           ],

           'Date',
           'Created_By',
           'Meter_Serial_Number',
           'Issued_To',
           'Store',
           'Admin_Incharge',
           'Project_Manager',
           'Driver_Name',
 ],
]); ?>

I have checked my count query and result query and both are returning me the correct count and result i.e. 8 items. I don't know why the summary is not displaying correctly.

Any help would be highly appreciated.

来源:https://stackoverflow.com/questions/47615466/yii2-grid-view-showing-wrong-count-of-items

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!