@@ -9,32 +9,21 @@ The preferred way to install this extension is through [composer](http://getcomp
99Either run
1010
1111```
12- composer require --prefer-dist integready/yii2-bulkactionscheckboxcolumn "@dev "
12+ composer require --prefer-dist integready/yii2-bulkactionscheckboxcolumn "~1.0 "
1313```
1414
1515or add
1616
1717```
18- "integready/yii2-bulkactionscheckboxcolumn": "@dev "
18+ "integready/yii2-bulkactionscheckboxcolumn": "~1.0 "
1919```
2020
2121to the require section of your ` composer.json ` file.
2222
23- Inserting a widget in GridView :
23+ Usage example :
2424--
25+ ###### GridView id must be set.
2526
26- ### Included variables (` #INCLUDED ` ):
27- ###### # These are NOT variables, you do not need to write them into the code, replace them with the correct strings or your variables! They are for what would be clear where you need to write the same para- meters.
28- * ` $idGrid // string `
29- * ` $fieldFirst // string `
30- * ` $itemsFirst // array(1 => 'On', 0 => 'Off') `
31- * ` $nameActionFirst // string `
32- * ` $fieldNext // string `
33- * ` $itemsNext // array(1 => 'On', 0 => 'Off') `
34- * ` $nameActionNext // string `
35- * ` $perPageName // string `
36-
37- ### Example:
3827* index.php ` (View) ` :
3928``` php
4029<?php
@@ -43,23 +32,29 @@ use kartik\grid\GridView;
4332
4433?>
4534<?= GridView::widget([
46- 'id' => $idGrid, #INCLUDED
47- 'dataProvider' => $dataProvider,
48- 'filterModel' => $searchModel,
49- 'columns' => [
35+ 'id' => 'books-grid',
36+ 'dataProvider' => $dataProvider,
37+ 'filterModel' => $searchModel,
38+ 'columns' => [
5039 [
51- 'class' => 'integready\bulkactionscheckboxcolumn\BulkCheckboxColumn',
52- 'elements' => [
40+ 'class' => 'integready\bulkactionscheckboxcolumn\BulkCheckboxColumn',
41+ 'elements' => [
5342 [
54- 'label' => 'Text first button',
55- 'field' => $fieldFirst, #INCLUDED
56- 'items' => $itemsFirst, #INCLUDED
43+ 'label' => 'Change Availability',
44+ 'field' => 'available',
45+ 'items' => [
46+ 1 => 'Yes',
47+ 0 => 'No',
48+ ],
5749 ],
5850 // ...Many elements
5951 [
60- 'label' => 'Text next button',
61- 'field' => $fieldNext, #INCLUDED
62- 'items' => $itemsNext, #INCLUDED
52+ 'label' => 'Change International Shipping',
53+ 'field' => 'intl_shipping',
54+ 'items' => [
55+ 1 => 'Yes',
56+ 0 => 'No',
57+ ],
6358 ]
6459 ],
6560 ],
@@ -68,42 +63,42 @@ use kartik\grid\GridView;
6863]); ?>
6964```
7065
71- * SiteController .php ` (Controller) ` :
66+ * BookController .php ` (Controller) ` :
7267``` php
7368<?php
7469
7570namespace app\controllers;
7671
7772use Yii;
7873use yii\web\Controller;
79- use backend\models\Site ;
74+ use backend\models\Book ;
8075use yii\helpers\ArrayHelper;
81- use backend\models\SiteSearch;
82- use integready\bulkactionscheckboxcolumn\BulkStatusAction;
76+ use backend\models\BookSearch;
8377
8478/**
85- * SiteController implements the CRUD actions for Site model.
79+ * BookController implements the CRUD actions for Site model.
8680 */
87- class SiteController extends Controller
81+ class BookController extends Controller
8882{
8983 /**
9084 * @inheritdoc
9185 */
9286 public function actions()
9387 {
9488 return ArrayHelper::merge(parent::actions(), [
95- $nameActionFirst => [ #INCLUDED
96- 'class' => BulkStatusAction::className(),
97- 'modelClass' => Site::className(),
98- 'gridId' => $idGrid, #INCLUDED
99- 'statusField' => $fieldFirst, #INCLUDED
89+ 'bulk_available' => [
90+ 'class' => BulkCheckboxAction::className(),
91+ 'modelClass' => Book::className(),
92+ 'gridId' => 'books-grid',
93+ 'statusField' => 'available',
94+ 'updateType' => BulkCheckboxAction::UPDATE_TYPE_ONEBYONE,
10095 ],
10196 // ...Many actions
102- $nameActionNext => [ #INCLUDED
103- 'class' => BulkStatusAction ::className(),
104- 'modelClass' => Site ::className(),
105- 'gridId' => $idGrid, #INCLUDED
106- 'statusField' => $fieldNext, #INCLUDED
97+ 'bulk_intl_shipping' => [
98+ 'class' => BulkCheckboxAction ::className(),
99+ 'modelClass' => Book ::className(),
100+ 'gridId' => 'books-grid',
101+ 'statusField' => 'intl_shipping',
107102 ],
108103 ]);
109104 }
@@ -115,11 +110,11 @@ class SiteController extends Controller
115110 */
116111 public function actionIndex()
117112 {
118- $this->runAction($nameActionFirst); #INCLUDED
113+ $this->runAction('bulk_available');
119114 // ...Many actions with run
120- $this->runAction($nameActionNext); #INCLUDED
115+ $this->runAction('bulk_intl_shipping');
121116
122- $searchModel = new SiteSearch ();
117+ $searchModel = new BookSearch ();
123118 $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
124119
125120 return $this->render('index', [
0 commit comments