在我的yii2项目中,我使用Dropdown在gridline中显示actionColumn中的操作。问题是,当数据行数少于3或4时(只显示足够的空间来显示所有操作),下拉列表会完全显示 - 参见图片1。但是当有足够的行和空格时,下拉列表会正确显示(参见图2)。
我尝试通过更改z-index的值来修复它,但没有运气。 如果有人愿意帮助我会非常感激。
图片-1
这是我的代码:
['class' => 'yii\grid\ActionColumn',
'contentOptions' => ['style' => 'width:10%;'],
'header'=>'Actions',
'template' => '{all}',
'buttons' => [
'all' => function ($url, $model, $key) {
return ButtonDropdown::widget([
'encodeLabel' => false, // if you're going to use html on the button label
'label' => 'Choisir',
'dropdown' => [
'encodeLabels' => false, // if you're going to use html on the items' labels
'items' => [
[
'label' => \Yii::t('yii', '<i class="icon-search4"></i> Voir'),
'url' => ['view', 'id' => $key],
],
[
'label' => \Yii::t('yii', '<i class="icon-pencil5"></i> Modifier'),
'url' => ['update', 'id' => $key],
'visible' => true,
],
[
'label' => \Yii::t('yii', '<i class="icon-list"></i> Valider'),
'url' => ['validate', 'id' => $key],
'visible' => true, // if you want to hide an item based on a condition, use this
],
/*[
'label' => \Yii::t('yii', "<i class='icon-city'></i> Voir le vendeurAgence"),
'url' => ['annonces', 'agence_id' => $model->vendor_id],
'visible' => true, // if you want to hide an item based on a condition, use this
],*/
[
'label' => \Yii::t('yii', '<i class="icon-bin"></i> Supprimer'),
'linkOptions' => [
'data' => [
'method' => 'post',
'confirm' => \Yii::t('yii', 'Voulez-vous vraiment supprimer cette vente ?'),
],
],
'url' => ['delete', 'id' => $key],
'visible' => true, // same as above
],
],
'options' => [
'class' => 'dropdown-menu-right', // right dropdown
],
],
'options' => [
'class' => 'btn-default',
'style' => 'padding-left: 5px; padding-right: 5px;', // btn-success, btn-info, et cetera
],
'split' => true, // if you want a split button
]);
},
],
图片-2