Advertisement
krot

yii2 GridView ActionColumn customization

Feb 20th, 2018
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.23 KB | None | 0 0
  1. echo GridView::widget(
  2.     [
  3.         'dataProvider' => $pList,
  4.             'showOnEmpty'=>true,
  5.        
  6.            'columns' => [
  7.              
  8.              [
  9.                'label' =>"Поле1",
  10.                'attribute' => 'field1',
  11.                'format' =>  'text'  //=>"raw", "text", "html", ['date', 'php:Y-m-d']).
  12.  
  13.                 'contentOptions' => ['class' => 'text-center'],
  14.                  'headerOptions' => ['class' => 'text-center']
  15.  
  16.             ],
  17.            
  18.             [
  19.                'label' =>"Поле2",
  20.                'attribute' => 'field2',
  21.                'format' =>  'raw',
  22.                'value'=>function($data){return $data['field2']?'<span class="icon-u">&#10004;</span>':''; }
  23.                
  24.             ],
  25.             ['class' => 'yii\grid\ActionColumn',
  26.             'buttons' => [
  27.                'update' => function ($url, $model, $key) use($myVariable) {
  28.                    return Html::a('','', ['class'=>'glyphicon glyphicon-pencil','data-cmd'=>'edit','data-id'=>$key]);
  29.                    },
  30.                 'delete' => function ($url, $model, $key) use($myVariable) {
  31.                    return Html::a('','', ['class'=>'glyphicon glyphicon-trash','data-cmd'=>'delete','data-id'=>$key]);
  32.                    },  
  33.                 'view' => function ($url, $model, $key) use($myVariable) {
  34.                    return '';
  35.                    }  
  36.                    
  37.                    
  38.             ],
  39.            
  40.             ],
  41.            
  42.          
  43.            ],
  44.            
  45.            
  46.     ]
  47. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement