nick-denry/yii2-filter-action-column Yii2 Gridview ActionColumn component with custom filter content field

actioncolumnyii2gridviewfiltercontent

993323

ActionColumn with filter content support for Yii2 GridView


Provides ActionColumn with filterContent option for yii2 GridView (ActionColumn header button)

Latest Stable Version Total Downloads Latest Unstable Version License

Preview

With AdminLTE

Preview

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist nick-denry/yii2-filter-action-column

or add

"nick-denry/yii2-filter-action-column": "^0.1.0"

to the require section of your composer.json file.

Usage

  1. Setup

    1.1. In your GridView view

    use nickdenry\grid\FilterContentActionColumn;

    1.2. Replace your default ActionColumn with

    [
        '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 */
    ],
  2. Additional options per action button

    Extension provides GridView action buttons additional options by name, i.e.

    Set individual class per each button:

    [
        '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
    ],

    or set buttons as usual:

    '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',
            ]);
        }
    ],
  3. Setup buttons classes per application.

    3.1. Via DI in your app config

    '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'],
                ],
            ],
        ],
    ],

    Additional information:

    3.2. If you want to override some default button, but keep it's "global" per-application class attribute

    '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',
                ]
            );
        },
    ]
  4. Customize delete confirmation text

    via deleteConfirmText property

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

    or simply

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

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



0.1.2 is the latest of 3 releases



MIT license
Stats
2 github stars & 0 github forks
0 downloads in the last day
1 downloads in the last 30 days
17 total downloads