如何隐藏kartik中的删除图标详细信息视图yii2?

时间:2016-10-06 06:28:30

标签: yii2-advanced-app

我正在使用Kartik / Detail View。我只想在面板中显示编辑按钮并隐藏面板中的删除图标。我的代码是:

<?= DetailView::widget([

    'model' => $model,
    'mode' => 'view',
    'bordered' => true,
    'striped' => true,
    'panel' => [
        'heading' => $this->title,
        'type' => DetailView::TYPE_INFO,
    ],
   'container' => ['id'=>'kv-demo'],
    'responsive' => true,
    'hover' => true,
    'hAlign'=>true,
    'vAlign'=>true,

    'fadeDelay'=>true,
        'attributes' => [

            'business_name',                
            'address2',
            'city',
            'state',
            'zip',
            'telephone',
            'fax',
            'email:email',
        ],
    ]) ?>

如何隐藏删除图标?

2 个答案:

答案 0 :(得分:1)

http://demos.krajee.com/detail-view#option-buttons1

使用&#39;按钮1&#39; =&GT; &#39; {更新}&#39;,隐藏删除。

<?= DetailView::widget([

'model' => $model,
'mode' => 'view',
'bordered' => true,
'striped' => true,
'panel' => [
    'heading' => $this->title,
    'type' => DetailView::TYPE_INFO,
],
'buttons1' => '{update}',

答案 1 :(得分:-1)

您可以使用以下选项从view文件夹的_columns.php文件执行此操作 在这里,您可以添加需要在详细视图中显示的操作的模板(在此示例中使用视图操作,并在视图中显示带有fa-gear图标的分配)

[
    'class' => 'kartik\grid\ActionColumn',
    'dropdown' => false,
    'vAlign'=>'middle',
    'template' => '{view}',
    'urlCreator' => function($action, $model, $key, $index) {
        return Url::to([$action,'id'=>$key]);
    },
    'buttons'=>[
        'view' => function ($url, $model, $key) {
            return Html::a('<span class="fa fa-gears"> Asign</span>', ['view', 'id'=>$model->id],['title'=>'Asign','role'=>'modal-remote','data-toggle'=>'tooltip']);
        },
    ]
],