https://github.com/integready/yii2-bulkactionscheckboxcolumn
Yii2 modified GridView CheckBoxColumn component with ability to create buttons for bulk actions with selected rows. Use with Kartik's GridView.
https://github.com/integready/yii2-bulkactionscheckboxcolumn
bulk-actions checkboxcolumn gridview gridview-extensions yii2
Last synced: 4 months ago
JSON representation
Yii2 modified GridView CheckBoxColumn component with ability to create buttons for bulk actions with selected rows. Use with Kartik's GridView.
- Host: GitHub
- URL: https://github.com/integready/yii2-bulkactionscheckboxcolumn
- Owner: IntegReady
- License: bsd-3-clause
- Created: 2018-02-01T15:20:12.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-12-03T17:23:46.000Z (almost 6 years ago)
- Last Synced: 2024-12-03T14:48:33.200Z (10 months ago)
- Topics: bulk-actions, checkboxcolumn, gridview, gridview-extensions, yii2
- Language: PHP
- Homepage:
- Size: 17.6 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Bulk actions checkbox column
============================Installation
------------The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
composer require --prefer-dist integready/yii2-bulkactionscheckboxcolumn "~1.0"
```or add
```
"integready/yii2-bulkactionscheckboxcolumn": "~1.0"
```to the require section of your `composer.json` file.
Usage example:
--
###### GridView id must be set.* index.php `(View)`:
> **Only one button is type to _```BulkCheckboxColumn::BUTTON_TYPE_CUSTOM_JS```_!**
```php= GridView::widget([
'id' => 'books-grid',
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'layout' => '{toolbar}\n{summary}\n{items}\n{pager}', // {toolbar} must be included in 'layout' section
'columns' => [
[
'class' => BulkCheckboxColumn::className(),
'elements' => [
[
'label' => 'Change Availability',
'field' => 'available',
'buttonClass' => 'btn btn-primary',
'buttonOptions' => [
'data' => [
'button' => 'change',
],
],
'items' => [
1 => 'Yes',
0 => 'No',
],
'visible' => false,
],
[
'label' => 'Change International Shipping',
'field' => 'intl_shipping',
'buttonClass' => 'btn btn-success',
'items' => [
1 => 'Yes',
0 => 'No',
],
],
[
'label' => 'Change Author',
'field' => 'author_book',
'buttonClass' => 'btn btn-info',
'buttonType' => BulkCheckboxColumn::BUTTON_TYPE_CUSTOM_JS,
'customJs' => 'function(event, gridId, ids) { /* ... */ }',
]
// ...Other elements
],
],
// Other columns
],
]); ?>
```* BookController.php `(Controller)`:
```php
[
'class' => BulkCheckboxAction::className(),
'modelClass' => Book::className(),
'gridId' => 'books-grid',
'statusField' => 'available',
'updateType' => BulkCheckboxAction::UPDATE_TYPE_ONEBYONE,
],
// ...Many actions
'bulk_intl_shipping' => [
'class' => BulkCheckboxAction::className(),
'modelClass' => Book::className(),
'gridId' => 'books-grid',
'statusField' => 'intl_shipping',
],
]);
}/**
* Index page
*
* @return mixed
*/
public function actionIndex()
{
$this->runAction('bulk_available');
// ...Many actions with run
$this->runAction('bulk_intl_shipping');$searchModel = new BookSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}// Other actions and methods
}
```