PHP code example of nick-denry / yii2-filter-action-column

1. Go to this page and download the library: Download nick-denry/yii2-filter-action-column library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nick-denry / yii2-filter-action-column example snippets


    use nickdenry\grid\FilterContentActionColumn;
    

    [
        'class' => FilterContentActionColumn::className(),
        // Add your own filterContent
        'filterContent' => function()
        {
            return '<div class="btn-group"> '.
                Html::a('<i class="fa fa-search"></i> Search', ['#'], [
                  'class' => 'btn btn-default search-filter', 'title' => 'Find page',
                ]).
                Html::a('<i class="fa fa-times"></i>', [''], [
                  'class' => 'btn btn-default reset-search-filter', 'title' => 'Reset filter',
                ]).
            '</div>';
        },
        /* Another actionColumn options */
    ],
    

    [
        'class' => FilterContentActionColumn::className(),
        // Set custom classes
        'buttonAdditionalOptions' => [
            'view' => ['class' => 'btn btn-lg btn-success'],
            'update' => ['class' => 'btn btn-default btn-sm'],
            'delete' => ['class' => 'btn btn-danger btn-sm'],
        ],
        ...
        // Add your own filterContent
    ],
    

    'buttons' => [
        'view' => function($url, $model, $key) {
            return Html::a(
                Html::tag('span', '', ['class' => "glyphicon glyphicon-eye-open"]),
                ['some/url'],
                [
                    'class' => 'btn btn-default btn-sm', // Here is simple string class
                    'target' => '_blank',
            ]);
        }
    ],
    

    'container' => [
        'definitions' => [
            nickdenry\grid\FilterContentActionColumn::class => [
                'buttonAdditionalOptions' => [
                    'view' => ['class' => 'btn btn-default btn-sm'],
                    'update' => ['class' => 'btn btn-default btn-sm'],
                    'delete' => ['class' => 'btn btn-danger btn-sm'],
                    // You could also set your "extra" button class
                    // like you point it in "template" option
                    // i.e. 'template' => '{view} {update} {delete} {extra}',
                    'extra' => ['class' => 'btn btn-success btn-sm'],
                ],
            ],
        ],
    ],
    

    'buttons' => [
        'view' => function($url, $model, $key, $additionalOptions) {
            return Html::a(
                Html::tag('span', '', ['class' => "glyphicon glyphicon-eye-open"]),
                ['some/url'],
                [
                    'class' => $additionalOptions['class'],
                    'target' => '_blank',
                ]
            );
        },
    ]
    

    [
        'class' => FilterContentActionColumn::className(),
        // Confirmation text
        'deleteConfirmText' => function($model) {
            return 'Are you sure you want to delete "'.$model->title.'" page?';
        },
        ...
        // Add your own filterContent
    ],
    

    [
        'class' => FilterContentActionColumn::className(),
        // Confirmation text
        'deleteConfirmText' => 'Custom confirmation',
        ...
        // Add your own filterContent
    ],