GridView from ArrayDataProvider

Web Tips Q & ACategory: Krajee Yii2 ExtensionsGridView from ArrayDataProvider
miniportal asked 1 year ago

Hello! I’m working with your grid and I love it, but I’m having some trouble when I try to fill the grid with a arrayData Provider.
 
My dataProvider was created:
$dataProvider = new ArrayDataProvider([
‘allModels’ => $model->examesLaboratoriais, //Thats the array bellow
]);
Thats the array:
Array ( [0] => Array ( [data] => 2016-11-25 [id_medico] => 1 [0] => Array ( [exame1] => 10 ) [1] => Array ( [exame2] => 50 ) [2] => Array ( [exame3] => 35 ) [3] => Array ( [exame4] => 45 ) ) [1] => Array ( [data] => 2016-11-22 [id_medico] => 1 [0] => Array ( [exameA] => 10 ) [1] => Array ( [exameB] => 50 ) [2] => Array ( [exameC] => 35 ) [3] => Array ( [exameD] => 45 ) ) )
 
And there is the dataProvider:
yii\data\ArrayDataProvider Object ( [key] => [allModels] => Array ( [0] => Array ( [data] => 2016-11-25 [id_medico] => 1 [0] => Array ( [exame1] => 10 ) [1] => Array ( [exame2] => 50 ) [2] => Array ( [exame3] => 35 ) [3] => Array ( [exame4] => 45 ) ) [1] => Array ( [data] => 2016-11-22 [id_medico] => 1 [0] => Array ( [exameA] => 10 ) [1] => Array ( [exameB] => 50 ) [2] => Array ( [exameC] => 35 ) [3] => Array ( [exameD] => 45 ) ) ) [modelClass] => [id] => [_sort:yii\data\BaseDataProvider:private] => [_pagination:yii\data\BaseDataProvider:private] => [_keys:yii\data\BaseDataProvider:private] => [_models:yii\data\BaseDataProvider:private] => [_totalCount:yii\data\BaseDataProvider:private] => [_events:yii\base\Component:private] => Array ( ) [_behaviors:yii\base\Component:private] => )
 
My grid is:
echo GridView::widget([
‘dataProvider’ => $dataProvider,
// ‘filterModel’ => $searchModel,
‘export’=>false,
‘columns’ =>$model->tiposExamesLaboratoriais
]);
 
The grid is showing with all collumns, but all cells are (not set).
 
Can you help me?
Thanks.
 

Login or register to contribute or comment.

Login   Register