且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在yii2中向网格视图添加按钮

更新时间:2023-11-24 16:08:40

您还可以像这样将按钮(或任意多个)添加到现有操作列中

You can also add the button (or as many as you like) to the existing action column like this

<?= GridView::widget([
    ::
    ::
    'columns' => [
        [
            'class' => 'yii\grid\ActionColumn',
            'template' => '{view} {update} {delete} {myButton}',  // the default buttons + your custom button
            'buttons' => [
                'myButton' => function($url, $model, $key) {     // render your custom button
                    return Html::a(..);
                }
            ]
        ]
        ::
        ::
        'currencyCode'
    ]   
]); ?>