如何在每个页面列中显示分离的独立GridView表(在我的情况下来自<foreach collection="auditLogs" item="auditLog" open="(" separator=" UNION ALL " close=")"> >
SELECT 1 as entityId, 1 as periodId FROM DUAL
</foreach>
),比如Dashboard?
答案 0 :(得分:1)
尝试这种方式
视图
// Firts Column
<div class= 'col-md-6'>
<?php
echo GridView::widget([
'dataProvider' => $dataProvider1,
'filterModel' => $searchModel1,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
.....
],
]);
?>
</div>
// separator column
<div class='col-md-1'></div>
// Second column
<div class='col-md-5'>
<?php
echo GridView::widget([
'dataProvider' => $dataProvider2,
'filterModel' => $searchModel2,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
.....
],
]);
?>
</div>
for controller
public function actionIndex()
{
// Migration already done
$searchModel1 = new YuorFirtsModelSearch();
$dataProvider1 = $searchModel1->search(Yii::$app->request->queryParams);
$searchModel2 = new YuorSecodnModelSearch();
$dataProvider2 = $searchModel2->search(Yii::$app->request->queryParams);
// Render All
return $this->render('indexNew', [
'searchModel1' => $searchModel1,
'dataProvider1' => $dataProvider1,
'searchModel2' => $serachModel2,
'dataProvider2' => $dataProvider2,
]);
}