CArrayDataProvider with CGridView pagination Yii

前端 未结 2 1436
花落未央
花落未央 2021-01-21 22:54

I\'m trying to do a pagination on a CGridView using CArrayDataProvider (my $rawData is a custom array - not from a DB/model). So, In the c

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-21 23:35

    Not sure it will solve your problem, but in your CArrayDataProvider you use id to define the name of the key field instead of keyField. You could try the following:

    $dataProvider=new CArrayDataProvider($users, array(
        'id'=>'users',
        'keyField' => 'id', 
        'keys'=>array('id','name', 'surname', 'phone', 'address'),
        'sort'=>array(
            'attributes'=>array(
                'name', 'surname', 'phone', 'address'
            ),
        ),
        'pagination'=>array(
            'pageSize'=>15,
        ),
    ));
    

提交回复
热议问题