Blame view

thread/widgets/grid/kartik/CheckboxColumn.php 1.29 KB
d1f8bd40   Alexey Boroda   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  <?php
  
  namespace thread\widgets\grid\kartik;
  
  use Closure;
  use yii\helpers\{
      Html, Url
  };
  
  /**
   * Class CheckboxColumn
   *
   * @package backend\components\grid\kartik
   * @author Daria Kharlan
   * @copyright (c) 2015, VipDesign
   */
  class CheckboxColumn extends \kartik\grid\BooleanColumn
  {
  
      /**
       * Renders a data cell.
       * @param mixed $model the data model being rendered
       * @param mixed $key the key associated with the data model
       * @param integer $index the zero-based index of the data item among the item array returned by [[GridView::dataProvider]].
       * @return string the rendering result
       */
      public function renderDataCell($model, $key, $index)
      {
          if ($this->contentOptions instanceof Closure) {
              $options = call_user_func($this->contentOptions, $model, $key, $index, $this);
          } else {
              $options = $this->contentOptions;
          }
          $icon = Html::a($this->renderDataCellContent($model, $key, $index), '#', [
              'class' => 'checkbox-button',
              'data' => [
                  'action' => Url::toRoute([$this->attribute, 'id' => $key]),
              ],
              'onclick' => 'return false;'
          ]);
  
          Html::addCssStyle($options, 'text-align:center;');
  
          return Html::tag('td', $icon, $options);
      }
  
  }