-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSelect2Column.php
More file actions
41 lines (32 loc) · 1.3 KB
/
Copy pathSelect2Column.php
File metadata and controls
41 lines (32 loc) · 1.3 KB
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
<?php
namespace dacduong\inlinegrid;
use kartik\grid\GridView;
use kartik\select2\Select2;
use Yii;
use yii\helpers\Html;
class Select2Column extends TextInputColumn
{
public $name = 'ddselect2';
public $cssClass = 'dd-row-select2';
public $pageSummaryFunc = GridView::F_COUNT;
public $modelFnc = 'getAvailableObject';
/**
* @inheritdoc
*/
protected function renderDataCellContent($model, $key, $index)
{
if ($this->content === null) {
$value = $this->getDataCellValue($model, $key, $index);
$this->controlOptions['data'] = call_user_func(array($model, $this->modelFnc));
$this->controlOptions['model'] = $model;
$this->controlOptions['attribute'] = $this->attribute;
$this->controlOptions['options']['name'] = $this->name;
$this->controlOptions['options']['class'] = 'value-'.$this->attribute;
unset($this->controlOptions['class']);//class in OOP not css
$this->controlOptions['options']['id'] = Yii::$app->security->generateRandomString(10);
return Select2::widget($this->controlOptions).$this->help_block_str;
} else {
return parent::renderDataCellContent($model, $key, $index);
}
}
}