问题
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