定制 mickgeek/yii2-actionbar 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mickgeek/yii2-actionbar

最新稳定版本:1.2.0

Composer 安装命令:

composer require mickgeek/yii2-actionbar

包简介

A control bar with bulk actions for the GridView widget.

README 文档

README

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.

统计信息

  • 总下载量: 43.26k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 34
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 34
  • Watchers: 3
  • Forks: 12
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固