Answer the question
In order to leave comments, you need to log in
How to insert one gridview view into another view?
I have this same code found in different places
<div class="history-balance-index">
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
['attribute' => 'user_id',
'value' => function ($model) {
return $model->user->username;
}
],
[
'attribute' => 'balance',
'format' => 'raw',
'value' => function ($model) {
return $model->balance . '<br>
<span class="text-success">' . $model->credit . '</span>';
}
],
[
'attribute' => 'balance_up',
'format' => 'raw',
'value' => function ($model) {
return Html::tag('span', $model->balance_up . '<br>' . $model->credit_up . (($model->credit_up >= 0)), [
'class' => ($model->credit_up >= 0) ? 'text-success' : 'text-danger'
]);
}
],
[
'attribute' => 'type',
'filter' => Html::activeDropDownList(
$searchModel,
'type',
HistoryBalance::getSortLabels(),
[
'everyday' => 'каждый день',
'class' =>
'form-control form-control-sm'
]
),
],
'comment',
],
]); ?>
</div>
<?php
use common\models\HistoryBalance;
use yii\grid\GridView;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\ListView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\HistoryBalanceSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'History Balances');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="history-balance-index">
<!---->
<!-- <h1>--><?//= Html::encode($this->title) ?><!--</h1>-->
<!---->
<!-- <p>-->
<!-- --><?//= Html::a(Yii::t('app', 'Create History Balance'), ['create'], ['class' => 'btn btn-success']) ?>
<!-- </p>-->
<!---->
<!-- --><?//= GridView::widget([
// 'dataProvider' => $dataProvider,
// 'filterModel' => $searchModel,
// 'columns' => [
// ['class' => 'yii\grid\SerialColumn'],
//
// ['attribute' => 'user_id',
// 'value' => function ($model) {
// return $model->user->username;
// }
// ],
// [
// 'attribute' => 'balance',
// 'format' => 'raw',
// 'value' => function ($model) {
// return $model->balance . '<br>
// <span class="text-success">' . $model->credit . '</span>';
// }
// ],
// [
// 'attribute' => 'balance_up',
// 'format' => 'raw',
// 'value' => function($model) {
// return \yii\helpers\Html::tag('span', $model->balance_up . '<br>' . $model->credit_up . (($model->credit_up >= 0)), [
// 'class' => ($model->credit_up >= 0) ? 'text-success' : 'text-danger'
// ]);
// }
// ],
// [
// 'attribute' => 'type',
// 'filter' => Html::activeDropDownList(
// $searchModel,
// 'type',
// HistoryBalance::getSortLabels(),
// [
// 'everyday' => 'каждый день',
// 'class' =>
// 'form-control form-control-sm'
// ]
// ),
// ],
// 'comment',
//
// ],
// ]); ?>
<!-- --><?//= GridView::widget([
// 'dataProvider' => $dataProvider,
// 'pager' => [
// 'hideOnSinglePage' => true,
//// 'firstPageLabel' => Yii::t('main', 'First'),
// 'lastPageLabel' => Yii::t('new', 'new'),
// ],
//// 'itemView' => 'new',
// 'layout' => '<div class="box box-solid"><div class="box-header"><div class="pull-right">{summary}</div></div></div><div class="row">{items}</div>{pager}',
// ])?>
<?= $this->render('new') ?>
</div>
<?= $this->render('new') ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'pager' => [
'hideOnSinglePage' => true,
'firstPageLabel' => Yii::t('main', 'First'),
'lastPageLabel' => Yii::t('new', 'new'),
],
'itemView' => 'new',
'layout' => '<div class="box box-solid"><div class="box-header"><div class="pull-right">{summary}</div></div></div><div class="row">{items}</div>{pager}',
])?>
Answer the question
In order to leave comments, you need to log in
The same is true, only you name your variables. In controller:
$userDataProvider = new ()
$userSeachModel = $userDataProvider->...
$postDataProvider = new ()
$postSeachModel = $postDataProvider->...
<?= GridView::widget([
'dataProvider' => $userDataProvider ,
'filterModel' => $userSeachModel,
'columns' => []
]?>
....
<?= GridView::widget([
'dataProvider' => $postDataProvider ,
'filterModel' => $postSeachModel,
'columns' => []
]?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question