2017 © Pedro Peláez
 

yii2-extension yii2-toggle-column

yii2 toggle column for update in gridview

image

dixonstarter/yii2-toggle-column

yii2 toggle column for update in gridview

  • Saturday, April 9, 2016
  • by dixonsatit
  • Repository
  • 6 Watchers
  • 14 Stars
  • 536 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 2 Open issues
  • 3 Versions
  • 6 % Grown

The README.md

Yii2 Toggle Column

yii2 toggle column for update in gridview, (*1)

, (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

php composer.phar require --prefer-dist dixonstarter/yii2-toggle-column "*"

or add, (*5)

"dixonstarter/yii2-toggle-column": "*"

to the require section of your composer.json file., (*6)

Usage

GridView

use yii\grid\GridView;
use yii\widgets\Pjax;

//.....


= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'tableOptions'=>['class'=>'table table-hover'],
    'columns' => [

      //.....
      [
        'attribute'=>'status',
        'class'=>'\dixonstarter\togglecolumn\ToggleColumn'
      ],
    ],
]); ?>

Controller

Add action for update, (*7)

class PostController extends Controller
{

    public function actions(){
      return [

          //.....

          'toggle-update'=>[
              'class'=>'\dixonstarter\togglecolumn\actions\ToggleAction',
              'modelClass'=>Post::className()
          ]
      ];
    }

    //...

}

Model

class Post extends \yii\db\ActiveRecord implements \dixonstarter\togglecolumn\ToggleActionInterface
{

  // ....

  use \dixonstarter\togglecolumn\ToggleActionTrait;
  public function getToggleItems()
  {
    // custom array for toggle update
    return  [
      'on' => ['value'=>1, 'label'=>'Publish'],
      'off' => ['value'=>0, 'label'=>'Panding'],
    ];
  }
}

Clean

, (*8)


[ 'attribute'=>'status', 'class'=>'\dixonstarter\togglecolumn\ToggleColumn', 'options'=>['style'=>'width:50px;'], 'linkTemplateOn'=>'<a class="toggle-column" data-pjax="0" href="{url}">{label}</a>', 'linkTemplateOff'=>'<a class="toggle-column" data-pjax="0" href="{url}">{label}</a>' ],

Button

, (*9)


[ 'attribute'=>'status', 'class'=>'\dixonstarter\togglecolumn\ToggleColumn', 'options'=>['style'=>'width:50px;'], 'linkTemplateOn'=>'<a class="toggle-column btn btn-default btn-xs btn-block" data-pjax="0" href="{url}">{label}</a>', 'linkTemplateOff'=>'<a class="toggle-column btn btn-default btn-xs btn-block" data-pjax="0" href="{url}">{label}</a>' ],

Icon

, (*10)


[ 'attribute'=>'status', 'class'=>'\dixonstarter\togglecolumn\ToggleColumn', 'options'=>['style'=>'width:50px;'], 'linkTemplateOn'=>'<a class="toggle-column btn btn-default btn-xs btn-block" data-pjax="0" href="{url}"><i class="glyphicon glyphicon-ok"></i> </a>', 'linkTemplateOff'=>'<a class="toggle-column btn btn-default btn-xs btn-block" data-pjax="0" href="{url}"><i class="glyphicon glyphicon-remove"></i> </a>' ],

Icon Color

, (*11)


[ 'attribute'=>'status', 'class'=>'\dixonstarter\togglecolumn\ToggleColumn', 'options'=>['style'=>'width:50px;'], 'linkTemplateOn'=>'<a class="toggle-column btn btn-warning btn-xs " data-pjax="0" href="{url}"><i class="glyphicon glyphicon-ok"></i> </a>', 'linkTemplateOff'=>'<a class="toggle-column btn btn-default btn-xs " data-pjax="0" href="{url}"><i class="glyphicon glyphicon-remove"></i> </a>' ],

Icon & Label

, (*12)


[ 'attribute'=>'status', 'class'=>'\dixonstarter\togglecolumn\ToggleColumn', 'options'=>['style'=>'width:50px;'], 'linkTemplateOn'=>'<a class="toggle-column btn btn-default btn-xs btn-block" data-pjax="0" href="{url}"><i class="glyphicon glyphicon-ok"></i> {label}</a>', 'linkTemplateOff'=>'<a class="toggle-column btn btn-default btn-xs btn-block" data-pjax="0" href="{url}"><i class="glyphicon glyphicon-remove"></i> {label}</a>' ],

Icon & Button color

, (*13)


[ 'attribute'=>'status', 'class'=>'\dixonstarter\togglecolumn\ToggleColumn', 'options'=>['style'=>'width:50px;'], 'linkTemplateOn'=>'<a class="toggle-column btn btn-primary btn-xs btn-block" data-pjax="0" href="{url}"><i class="glyphicon glyphicon-ok"></i> {label}</a>', 'linkTemplateOff'=>'<a class="toggle-column btn btn-default btn-xs btn-block" data-pjax="0" href="{url}"><i class="glyphicon glyphicon-remove"></i> {label}</a>' ],

The Versions

09/04 2016

dev-master

9999999-dev

yii2 toggle column for update in gridview

  Sources   Download

Apache-2.0

The Requires

 

by sathit seethaphon

extension yii2 gridview toggle column

09/04 2016

dev-develop

dev-develop

yii2 toggle column for update in gridview

  Sources   Download

Apache-2.0

The Requires

 

by sathit seethaphon

extension yii2 gridview toggle column

09/04 2016

1.0.0

1.0.0.0

yii2 toggle column for update in gridview

  Sources   Download

Apache-2.0

The Requires

 

by sathit seethaphon

extension yii2 gridview toggle column