An open API service indexing awesome lists of open source software.

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.

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
}
```