0

我在下面有这段代码,它将生成患者列表。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'
         ],

    ])
4

0 回答 0