public function init() { $this->editable['options']['display'] = 'js:function(value, sourceData) { if (typeof sourceData === "undefined") { return false; } var selected = $.grep(sourceData, function(o){ return value == o.value; })[0], itemsOptions = ' . json_encode($this->options) . '; var item = itemsOptions[value]; var itemColor = "", itemClass = ""; var html = selected.text; if(item){ itemColor = item["color"] ? "style=\'background-color: " + item["color"] + "\'" : ""; itemClass = "class=\'label " + (item["class"] ? item["class"] : "") + "\'"; html = "<div " + itemClass + " " + itemColor + "><span style=\'border-bottom: 1px dashed;\'>" + selected.text + "</span></div>" } $(this).html(html); }'; $this->editable = array_merge($this->editable, ['url' => $this->url ?: $this->grid->controller->createUrl('inline'), 'type' => 'select', 'mode' => 'right', 'params' => [Yii::app()->getRequest()->csrfTokenName => Yii::app()->getRequest()->csrfToken], 'source' => $this->source]); // если filter принудительно не поставили в false и он пустой, то берем данные для него из source if ($this->filter !== false && is_null($this->filter)) { $this->filter = $this->source; } if (is_array($this->filter) && $this->grid->filter) { $this->filter = CHtml::activeDropDownList($this->grid->filter, $this->name, $this->filter, ['id' => false, 'prompt' => '', 'class' => 'form-control']); } parent::init(); }
public function init() { /* if(empty($this->editable)) $this->editable = array( 'url' => $this->grid->controller->createUrl('inline'), 'emptytext' => '-', 'params' => array( Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken ) ); */ $editableParams = array('url' => $this->grid->controller->createUrl('inline'), 'emptytext' => '-', 'params' => array(Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken)); $this->editable = array_merge($editableParams, $this->editable); parent::init(); }