我有一个观点event
,它有一个额外的动作按钮,重定向到 这里checkin/index
页是我的GridView设置页面标题yii2
<?= GridView::widget([
'id'=>'event-table',
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
'title',
'location',
[
'class' => 'yii\grid\ActionColumn',
'template' => '{checkin/index} {view} {update} {delete} ',
'contentOptions' => ['class'=>'action-td'],
'buttons' => [
'checkin/index' => function ($url,$model) {
return Html::a('<div id="notification-container"><span data-pjax=false class="glyphicon glyphicon-user"></span>'.EventSearch::showCheckin($model->id) .'</div>', $url,['data-pjax' => true]);
},
]
],
]
]);
使用时点击该按钮会打开一个checkin/index
页,所以我想送其上点击按钮,使 的checkin/index
页面上,我可以使用该标题$this->title
行的title
有任何W AY通过对操作按钮数据点击 这里是我的checkin/index
代码
public function actionIndex()
{
$searchModel = new CheckinSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
我不能下面的代码使用的,因为我的$model
只会有event_id
作为相关表的价值和checkin/index
页我用GridView和关系,以显示标题直接使用event.title
$this->title = isset($dataProvider->models[0]->title) ? $dataProvider->models[0]->title : 'empty result';
你想通过网址传递数据? –
@InsaneSkulll我只需要设置页面的标题..无论如何我可以...流是这样的...在'事件/索引'行中gridview用户将点击动作列按钮,它会打开'特定记录的checkin/index'页面...所以我想获得用户点击的行的标题并将其传递到下一页以设置页面标题 –
您可以简单地通过url传递数据并让它们打开欲望页面并将其传递给页面标题。 –