Reputation: 1129
I have an array of data very similar to this
[
'name'=>'mark',
'age'=> '21'
'height'=> '190 cm'
]
I searched Google and all the results i found were using an active record object.
How do i use the gridview with an array of this sort?
Upvotes: 11
Views: 13283
Reputation: 804
You should use ArrayDataProvider (https://github.com/yiisoft/yii2/blob/master/framework/data/ArrayDataProvider.php)
$provider = new ArrayDataProvider([
'allModels' => $yourArray,
'sort' => [
'attributes' => ['id', 'username', 'email'],
],
'pagination' => [
'pageSize' => 10,
],
]);
Upvotes: 20