public function init() { parent::init(); $request = AH::merge(['wrapper' => 'results', 'term' => 'search:term'], $this->uses); $requests = []; $back_request = []; foreach ($request as $k => $v) { if ($k === 'term') { $requests[] = $v; } elseif (is_array($v)) { $requests[] = "{$k}:" . json_encode($v); $back_request[] = "{$k}:" . json_encode($v); } else { $requests[] = "{$k}:'{$v}'"; $back_request[] = "{$k}:'{$v}'"; } } \Yii::configure($this, ['format' => 'html', 'filterInputOptions' => ['id' => 'id'], 'filter' => Select2::widget(['attribute' => 'id', 'model' => $this->grid->filterModel, 'url' => Url::toRoute(['list']), 'settings' => ['ajax' => ['data' => new JsExpression('function(term,page) { return {' . implode(', ', $requests) . '}; }')], 'initSelection' => new JsExpression('function (elem, callback) { var id=$(elem).val(); $.ajax("' . Url::toRoute(['list']) . '?id=" + id, { dataType: "json", data : {' . implode(', ', $back_request) . '} }).done(function(data) { callback(data.results[0]); }); }')]])]); }
public function init() { parent::init(); \Yii::configure($this, ['attribute' => 'email', 'label' => \Yii::t('hipanel', 'Email'), 'format' => 'html', 'value' => function ($model) { return Html::a($model->client ?: $model->login, ['/client/contact/view', 'id' => $model->client ? $model->client_id : $model->id]); }, 'filterInputOptions' => ['email' => 'email'], 'filter' => Select2::widget(['attribute' => 'email', 'model' => $this->grid->filterModel, 'url' => Url::toRoute(['/client/contact/email-list'])])]); }
public function getDataCellValue($model, $key, $index) { $value = parent::getDataCellValue($model, $key, $index); if (array_key_exists($value, $this->items)) { return $this->items[$value]; } return $value; }
public function init() { parent::init(); Yii::configure($this, ['visible' => Yii::$app->user->identity->type !== 'client', 'attribute' => 'seller_id', 'label' => Yii::t('hipanel', 'Can Manage'), 'format' => 'html', 'value' => function ($model) { return Html::a($model->client, ['/client/client/view', 'id' => $model->client_id]); }, 'filterInputOptions' => ['id' => 'client_id'], 'filter' => Select2::widget(['attribute' => 'seller_id', 'model' => $this->grid->filterModel, 'url' => Url::toRoute(['/client/client/list']), 'settings' => ['ajax' => ['data' => new JsExpression('function(term,page) { return {"rename[text]":"login",wrapper:"results", manager_only:true, client_like:term}; }')], 'initSelection' => new JsExpression('function (elem, callback) { $.ajax("' . Url::toRoute(['/client/client/list']) . '?id=" + id, { dataType: "json", data : {"rename[text]":"login",wrapper:"results" } }).done(function(data) { callback(data.results[0]); }); }')]])]); }
/** * Creates column objects and initializes them. */ protected function initColumns() { if ($this->_columns) { foreach ($this->_columns as $name => $col) { if (is_string($col)) { $column = $this->createDataColumn($col); } else { $column = Yii::createObject(array_merge($col, ['class' => empty($col['class']) ? DataColumn::className() : __NAMESPACE__ . '\\' . $col['class'], 'grid' => $this])); } if (!$column->visible) { unset($this->_columns[$i]); continue; } $this->_columns[$i] = $column; } } if ($this->_columns) { foreach ($this->_columns as $column) { $column->init(); $filterValue = $this->filter && $column->name && isset($this->filter[$column->name]) ? $this->filter[$column->name] : null; $this->filterPrepared[$column->name] = $column->prepareFilterValue($filterValue); } } }
public function init() { parent::init(); //$this->contentOptions=['class'=>'align-center']; }
public function init() { parent::init(); }
public function renderViewLink($model, $key, $index) { $value = parent::renderDataCellContent($model, $key, $index); return Html::a($value, [$this->buildUrl('view'), 'id' => $model->id], ['class' => 'bold']); }
public function renderHeaderCell() { $this->headerHtmlOptions['width'] = '20px'; parent::renderHeaderCell(); }
/** * Adds multiple columns at the end of the array * the column should be an associative array, that can have 'label', 'id' and 'type' * @param array $cols */ public function addColumns(array $cols) { foreach ($cols as $col) { $this->cols[] = DataColumn::fromArray($col); } }
public function getDataCellValue($model, $key, $index) { return SwitchInput::widget(ArrayHelper::merge(['name' => 'swc' . $key . $model->id, 'pluginOptions' => ArrayHelper::merge($this->pluginOptions, ['state' => (bool) parent::getDataCellValue($model, $key, $index)])], $this->switchInputOptions)); }