All Projects → mickgeek → yii2-actionbar

mickgeek / yii2-actionbar

Licence: BSD-3-Clause license
A control bar with bulk actions for the GridView widget.

Programming Languages

PHP
23972 projects - #3 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to yii2-actionbar

yii2-grid-view-library
Highly enhanced GridView widget and grid components for Yii2
Stars: ✭ 57 (+78.13%)
Mutual labels:  grid, yii2
Yii2 Export
A library to export server/db data in various formats (e.g. excel, html, pdf, csv etc.)
Stars: ✭ 153 (+378.13%)
Mutual labels:  grid, yii2
tomanistor.com
Personal portfolio website and blog created with Hugo
Stars: ✭ 14 (-56.25%)
Mutual labels:  grid
NiftyGrid
DataGrid for Nette Framework
Stars: ✭ 34 (+6.25%)
Mutual labels:  grid
spreadsheet
Yii2 extension for export to Excel
Stars: ✭ 79 (+146.88%)
Mutual labels:  yii2
GMT.jl
Generic Mapping Tools Library Wrapper for Julia
Stars: ✭ 148 (+362.5%)
Mutual labels:  grid
yii2-fileapi-widget
Yii2 FileAPI widget.
Stars: ✭ 51 (+59.38%)
Mutual labels:  yii2
vue-layout-system
A pack of Vue components that solve daily layout problems
Stars: ✭ 31 (-3.12%)
Mutual labels:  grid
bootstrap-grid-ms
Missing grid range in Bootstrap 3, micro-small from 480-767px.
Stars: ✭ 34 (+6.25%)
Mutual labels:  grid
tetris-grid
◼️Lightweight and simple CSS grid
Stars: ✭ 16 (-50%)
Mutual labels:  grid
craft-grid
A field that lets you content manage CSS Grid in Craft CMS.
Stars: ✭ 18 (-43.75%)
Mutual labels:  grid
CSS-Responsive-Grid-Overlay
Easily adjustable grid overlay to make development discussions easier
Stars: ✭ 75 (+134.38%)
Mutual labels:  grid
yii2-fullcalendar-scheduler
Yii 2 component for easy fullcalendar scheduler integration
Stars: ✭ 24 (-25%)
Mutual labels:  yii2
yii2-js-urlmanager
That extension provide a way to create urls from your frontend part.
Stars: ✭ 53 (+65.63%)
Mutual labels:  yii2
luya-module-admin
Administration base module for all LUYA admin modules
Stars: ✭ 45 (+40.63%)
Mutual labels:  yii2
grid-trade-helper
📜A tool for generating grid trade data table.
Stars: ✭ 13 (-59.37%)
Mutual labels:  grid
gridss
A CSS Grid microlib.
Stars: ✭ 16 (-50%)
Mutual labels:  grid
yii2-admin-template
Yii2 application template targeted for backends.
Stars: ✭ 17 (-46.87%)
Mutual labels:  yii2
LazyWaimai-Api
基于Yii2框架的LazyWaimai Api端,REST API架构风格的,使用Oauth2进行身份认证
Stars: ✭ 42 (+31.25%)
Mutual labels:  yii2
yii2-highlight
Yii2 Highlight.js extension
Stars: ✭ 14 (-56.25%)
Mutual labels:  yii2

ActionBar

ActionBar is a Yii 2 widget that render the drop-down list for manipulation selected the GridView items and control buttons. The widget permits you to fully customize elements.

Screenshot

Installation

You can install the widget using Composer. Just run the following command under your application folder:

php composer.phar require --prefer-dist mickgeek/yii2-actionbar

Usage

use mickgeek\actionbar\Widget as ActionBar;

<?= ActionBar::widget([
    'grid' => 'user-grid',
]) ?>

But first, add the action to your controller:

public function actions()
{
    return [
        'delete-multiple' => [
            'class' => 'mickgeek\actionbar\DeleteMultipleAction',
            'modelClass' => 'app\models\User',
        ],
    ];
}

Note: You can write your action without using DeleteMultipleAction class.

Tip: For information about properties and methods of the widget, see the bundled DOCUMENTATION.md.

Examples

Below are two examples showing some features of the widget.

Advanced Bulk Actions

Advanced Bulk Actions Screenshot

The code in the view:

use yii\helpers\Url;
use mickgeek\actionbar\Widget as ActionBar;

<?= ActionBar::widget([
    'grid' => 'user-grid',
    'templates' => [
        '{bulk-actions}' => ['class' => 'col-xs-4'],
        '{create}' => ['class' => 'col-xs-8 text-right'],
    ],
    'bulkActionsItems' => [
        'Update Status' => [
            'status-active' => 'Active',
            'status-blocked' => 'Blocked',
        ],
        'General' => ['general-delete' => 'Delete'],
    ],
    'bulkActionsOptions' => [
        'options' => [
            'status-active' => [
                'url' => Url::toRoute(['update-status', 'status' => 'active']),
                'disabled' => !Yii::$app->user->can('updateUserStatus'),
            ],
            'status-blocked' => [
                'url' => Url::toRoute(['update-status', 'status' => 'blocked']),
                'disabled' => !Yii::$app->user->can('updateUserStatus'),
            ],
            'general-delete' => [
                'url' => Url::toRoute('delete-multiple'),
                'data-confirm' => 'Are you sure?',
                'disabled' => !Yii::$app->user->can('deleteUser'),
            ],
        ],
        'class' => 'form-control',
    ],
]) ?>

The code in the User controller:

public function actions()
{
    return [
        'delete-multiple' => [
            'class' => 'mickgeek\actionbar\DeleteMultipleAction',
            'modelClass' => 'app\models\User',
            'beforeDeleteCallback' => function ($action) {
                if (!Yii::$app->user->can('deleteOwnAccount', Yii::$app->getRequest()->post('ids'))) {
                    Yii::$app->getSession()->setFlash('error', 'You cannot delete your own account.');

                    $action->redirect();
                    Yii::$app->end();
                }
            },
            'afterDeleteCallback' => function ($action) {
                Yii::$app->getSession()->setFlash('success', 'The selected users have been deleted successfully.');
            },
        ],
    ];
}

public function actionUpdateStatus($status)
{
    ...
}

Custom Buttons

Custom Buttons Screenshot

The code:

use mickgeek\actionbar\Widget as ActionBar;

/* @var $model app\models\User */
<?= ActionBar::widget([
    'templates' => [
        '{back}' => ['class' => 'col-xs-4'],
        '{update} {delete}' => ['class' => 'col-xs-8 text-right'],
    ],
    'elements' => [
        'back' => Html::a(
            '<span class="glyphicon glyphicon-chevron-left"></span> ' . 'Back',
            ['/users/index'],
            ['class' => 'btn btn-default']
        ),
        'update' => Html::a(
            '<span class="glyphicon glyphicon-pencil"></span> ' . 'Update',
            ['/users/update', 'id' => $model->id],
            ['class' => 'btn btn-default']
        ),
        'delete' => Html::a(
            '<span class="glyphicon glyphicon-trash"></span> ' . 'Delete',
            ['/users/delete', 'id' => $model->id],
            ['class' => 'btn btn-default']
        ),
    ],
]) ?>

License

This extension is released under the BSD 3-Clause License. See the bundled LICENSE.md for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].