There are some differents data type, and these data will be rendered in each gridview based on their conditional value, if there are three different data, then render three different gridview. And so on. In one type of data we can just do it:
$allthings = GridView::widget([ 'id' => 'dataold', 'dataProvider' => $dataProvider, 'columns' => $gridColumns ]);
$dataProvider
here is Two-dimensional Arrays which each has key "type" column for data type classification. If there are five diffrent "type" then I want to loop five tables too. How? Possible?
1 Answers
Answers 1
Ok, I found the solution here.
Yii2 Dynamically render GridView
First I need to make the dataProvider in array
foreach ($categories as $category) { $dataProviders[] = new ActiveDataProvider([ 'query' => $category->getSeminars(), ]); }
Then I can loop it
foreach ($dataProviders as $dataProvider) { $this->render('_categoryRow', [ 'dataProvider' => $dataProvider, ]); }
Just as simple as that.
0 comments:
Post a Comment