在Yii2 for gridview中的视图按钮显示下拉列表,即下拉菜单中的view1,view2等
'template' => '{view}',
'buttons' => [
'view' => function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-eye-open"></span>',Url::to(['order/viewsubscription','id'=>$model->id]), ['title' => 'Update','style'=>'background:none;border:none']);
},
],
答案 0 :(得分:1)
添加下拉列表:
[
'class' => 'yii\grid\ActionColumn',
'contentOptions' => ['style' => 'width:260px;'],
'header'=>'Actions',
'template' => '{view}',
'buttons' => [
//view button
'view' => function ($url, $model) {
return '<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Dropdown Example
<span class="caret"></span></button>
<ul class="dropdown-menu">
<li>'.Html::a('<span class="glyphicon glyphicon-eye-open"></span>',Url::to(['order/viewsubscription','id'=>$model->id]), ['title' => 'Update','style'=>'background:none;border:none']).' </li>
<li>'.Html::a('<span class="glyphicon glyphicon-eye-open"></span>',Url::to(['order/viewsubscription','id'=>$model->id]), ['title' => 'Update','style'=>'background:none;border:none']).' </li>
</ul>
</div>';
},
],
],
答案 1 :(得分:1)
这是我正在使用的下拉菜单。
use yii\bootstrap\ButtonDropdown;
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update} {more}',
'buttons' => [
'more' => function ($url, $model, $key) {
return ButtonDropdown::widget([
'label' => Yii::t('app', 'More Actions'),
'tagName' => 'a',
'options' => [
'class' => 'label label-default'
],
'dropdown' => [
'options' => [
'class' => ['dropdown-menu-right'],
],
'items' => [
[
'label' => Yii::t('app', 'View Link1'),
'url' => [],
],
[
'label' => Yii::t('app', 'View Link2'),
'url' => [],
],
],
],
]);
}
],
],