我在gridview
中有pjax
在Actioncolumn
按钮上,我调用了不同的controller
操作。
例如,我的gridview位于event index
页面,其控制器为EventController
,但在该网格视图中actioncolumn
按钮之一,我正在调用CheckinController
行动。
只有在我不使用Pjax
时才能正常工作,否则只会刷新gridview
而url
也会更改,但它不会刷新页面
这是event
gridview
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<div class="common-button">
<p>
<?= Html::a('Create Event', ['create'], ['class' => 'btn btn-danger']) ?>
</p>
</div>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'rowOptions'=> function($modal, $key, $index, $grid) {
if ($modal->is_active == '0') {
return ['class' => 'danger action-tr' ];
} else
return ['class' => 'success action-tr'];
},
'columns' => [
[
'attribute' => 'interest_id',
'label' => 'Event Category',
'value' => 'interest.area_intrest',
],
'title',
'description:html',
'location',
'start_date',
[
'class' => 'yii\grid\ActionColumn',
'template' => '{checkin/index} {view} {update} {delete} ',
'contentOptions' => ['class'=>'action-td'],
'buttons' => [
'checkin/index' => function ($url) {
return Html::a('<span class="glyphicon glyphicon-user"></span>', $url);
},
]
],
]
]);
?>
答案 0 :(得分:1)
您应该在[ 'data-pjax' => true ]
按钮的锚标记选项中添加actionColumn
。
喜欢,
[
'class' => 'yii\grid\ActionColumn',
'template' => '{checkin/index} {view} {update} {delete} ',
'contentOptions' => ['class'=>'action-td'],
'buttons' => [
'checkin/index' => function ($url) {
return Html::a('<span class="glyphicon glyphicon-user"></span>', $url, ['data-pjax' => true]);
},
]
],