我下面有这段代码,它将生成患者列表。 Gridview摘要是准确的,但是我的分页不起作用。如果我添加id选项'id'=>'patientsList',它将在每个页面上显示所有患者。我该如何解决?这个问题有什么可能的解决方案?
对于我的提供者:
$provider = new ArrayDataProvider([
'allModels' => $patientData,
'pagination' => [
'pageSize' => 10,
],
'sort' => [
'attributes' => ['_id', 'pin', 'name', 'gender', 'dateOfBirth', 'room','status','unknown']
],
]);
然后用于设置gridview:
GridView::widget([
'dataProvider' => $provider,
'id' => 'patientsList',
'summary' => "Showing <b>{begin} - {end}</b> of <b>{totalCount}</b> patients.",
'rowOptions' => function ($model, $key, $index, $grid) {
if(isset($model['unknown']) &&$model['unknown']==1){
return [
'style' => 'cursor:pointer; color:red;',
'data-id' => $model['_id']
];
}
else{
return [
'style' => 'cursor:pointer',
'data-id' => $model['_id']
];
}
},
'columns' => [
'name',
'gender',
'room'
],
])