/** * Renders the data cell content. * @param mixed $model the data model * @param mixed $key the key associated with the data model * @param integer $index the zero-based index of the data model among the models array returned by [[GridView::dataProvider]]. * * @return string the rendering result * @throws InvalidConfigException */ public function renderDataCellContent($model, $key, $index) { $exception = false; $this->_editableOptions = $this->editableOptions; if (!empty($this->editableOptions) && $this->editableOptions instanceof Closure) { $this->_editableOptions = call_user_func($this->editableOptions, $model, $key, $index); } if (!is_array($this->_editableOptions)) { $this->_editableOptions = []; } if ($this->grid->pjax && empty($this->_editableOptions['pjaxContainerId'])) { $this->_editableOptions['pjaxContainerId'] = $this->grid->pjaxSettings['options']['id']; } if ($this->attribute !== null) { $this->_editableOptions['model'] = $model; $this->_editableOptions['attribute'] = '[' . $index . ']' . $this->attribute; } elseif (empty($this->_editableOptions['name']) && empty($this->_editableOptions['model'])) { $exception = true; } elseif (empty($this->_editableOptions['attribute'])) { $exception = true; } if ($exception) { throw new InvalidConfigException("You must setup either the 'attribute' for the EditableColumn OR setup the 'name' OR 'model'/'attribute' in '_editableOptions' (Exception raised for: key: '{$key}', index: '{$index}')."); } $this->_editableOptions['displayValue'] = parent::renderDataCellContent($model, $key, $index); $params = Html::hiddenInput('editableIndex', $index) . Html::hiddenInput('editableKey', $key); if (empty($this->_editableOptions['beforeInput'])) { $this->_editableOptions['beforeInput'] = $params; } else { $this->_editableOptions['beforeInput'] .= $params; } if ($this->refreshGrid) { $view = $this->grid->getView(); $grid = 'jQuery("#' . $this->grid->options['id'] . '")'; $script = <<<JS {$grid}.find('.kv-editable-input').each(function() { var \$input = \$(this); \$input.on('editableSuccess', function(){ {$grid}.yiiGridView("applyFilter"); }); }); JS; $view->registerJs($script); } return Editable::widget($this->_editableOptions); }
public function init() { Icon::map($this->grid->getView()); $this->registerTranslations(); parent::init(); // TODO: Change the autogenerated stub $this->value = function ($model, $key, $index, $widget) { $lockIcon = ''; if ($this->showLock) { if ($model->hasAttribute('locked') && $model->{$model->lockedAttribute}) { $lockIcon = Icon::show('eye-slash'); } else { $lockIcon = Icon::show('eye'); } } return Html::a($lockIcon . $model->{$this->attribute}, ['update', 'id' => $model->id], ['title' => self::t('messages', 'Edit item')]); }; }
/** * Renders the data cell content. * * @param mixed $model the data model * @param mixed $key the key associated with the data model * @param integer $index the zero-based index of the data model among the models array returned by * [[GridView::dataProvider]]. * * @return string the rendering result * @throws InvalidConfigException */ public function renderDataCellContent($model, $key, $index) { $readonly = $this->readonly; if ($readonly instanceof Closure) { $readonly = call_user_func($readonly, $model, $key, $index, $this); } if ($readonly === true) { return parent::renderDataCellContent($model, $key, $index); } $this->_editableOptions = $this->editableOptions; if (!empty($this->editableOptions) && $this->editableOptions instanceof Closure) { $this->_editableOptions = call_user_func($this->editableOptions, $model, $key, $index, $this); } if (!is_array($this->_editableOptions)) { $this->_editableOptions = []; } $options = ArrayHelper::getValue($this->_editableOptions, 'containerOptions', []); Html::addCssClass($options, $this->_css); $this->_editableOptions['containerOptions'] = $options; if ($this->grid->pjax && empty($this->_editableOptions['pjaxContainerId'])) { $this->_editableOptions['pjaxContainerId'] = $this->grid->pjaxSettings['options']['id']; } $strKey = $key; if (empty($key)) { throw new InvalidConfigException("Invalid or no primary key found for the grid data."); } elseif (!is_string($key) && !is_numeric($key)) { $strKey = serialize($key); } if ($this->attribute !== null) { $this->_editableOptions['model'] = $model; $this->_editableOptions['attribute'] = "[{$index}]{$this->attribute}"; $type = ArrayHelper::getValue($this->_editableOptions, 'inputType', Editable::INPUT_TEXT); } elseif (empty($this->_editableOptions['name']) && empty($this->_editableOptions['model']) || !empty($this->_editableOptions['model']) && empty($this->_editableOptions['attribute'])) { throw new InvalidConfigException("You must setup the 'attribute' for your EditableColumn OR set one of 'name' OR 'model' & 'attribute' in 'editableOptions' (Exception at index: '{$index}', key: '{$strKey}')."); } $val = $this->getDataCellValue($model, $key, $index); if (!isset($this->_editableOptions['displayValue']) && $val !== null && $val !== '') { $this->_editableOptions['displayValue'] = parent::renderDataCellContent($model, $key, $index); } $params = Html::hiddenInput('editableIndex', $index) . Html::hiddenInput('editableKey', $strKey); if (empty($this->_editableOptions['beforeInput'])) { $this->_editableOptions['beforeInput'] = $params; } else { $output = $this->_editableOptions['beforeInput']; $this->_editableOptions['beforeInput'] = function ($form, $widget) use($output, $params) { if ($output instanceof Closure) { return $params . call_user_func($output, $form, $widget); } else { return $params . $output; } }; } if ($this->refreshGrid) { $view = $this->grid->getView(); $grid = 'jQuery("#' . $this->grid->options['id'] . '")'; $script = <<<JS {$grid}.find('.{$this->_css}').each(function() { var \$el = \$(this); \$el.on('editableSuccess', function(){ {$grid}.yiiGridView("applyFilter"); }); }); JS; $view->registerJs($script); } return Editable::widget($this->_editableOptions); }
use kartik\export\ExportMenu; use kartik\grid\GridView; use kartik\grid\DataColumn; use yii\helpers\Html; use dosamigos\datepicker\DatePicker; use app\models\Faq; use yii\helpers\Url; $this->title = 'Faq'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="faq-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <p> <?php echo Html::a('Создать Faq', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'pjax' => true, 'export' => ['fontAwesome' => true], 'panel' => ['type' => GridView::TYPE_PRIMARY], 'columns' => [['class' => 'kartik\\grid\\SerialColumn'], 'title', 'status' => ['class' => DataColumn::className(), 'attribute' => 'status', 'filter' => Html::activeDropDownList($searchModel, 'status', Faq::$status, ['class' => 'form-control']), 'value' => function ($dataProvider) { return Faq::$status[$dataProvider->status]; }], ['class' => 'kartik\\grid\\ActionColumn', 'template' => '{update} {delete}{link}']], 'responsive' => true, 'hover' => true, 'toolbar' => ['{export}', '{toggleData}'], 'containerOptions' => ['style' => 'overflow: auto'], 'headerRowOptions' => ['class' => 'kartik-sheet-style'], 'filterRowOptions' => ['class' => 'kartik-sheet-style']]); ?> </div>
/** * Renders the header cell content. The default implementation simply renders [[header]]. This method may be * overridden to customize the rendering of the header cell. * * @return string the rendering result */ protected function renderHeaderCellContent() { if ($this->header !== null) { return parent::renderHeaderCellContent(); } $icon = $this->expandIcon; $css = 'kv-expand-header-icon kv-state-collapsed'; if ($this->defaultHeaderState === GridView::ROW_EXPANDED) { $icon = $this->collapseIcon; $css = 'kv-expand-header-icon kv-state-expanded'; } return "<div class='{$css}'>{$icon}</div>"; }
/** * @inheritdoc */ public function getDataCellValue($model, $key, $index) { $value = parent::getDataCellValue($model, $key, $index); if ($value !== null) { return $value ? $this->trueIcon : $this->falseIcon; } return $this->showNullAsFalse ? $this->falseIcon : $value; }
/** * Formatted footer cell content. * * @return string the rendering result */ protected function renderFooterCellContent() { if ($this->autoFooter) { return $this->grid->formatter->format($this->getFooterCellContent(), $this->format); } return parent::renderFooterCellContent(); }
/** * Renders the data cell content. * * @param mixed $model the data model * @param mixed $key the key associated with the data model * @param integer $index the zero-based index of the data model among the models array returned by * [[GridView::dataProvider]]. * * @return string the rendering result * @throws InvalidConfigException */ public function renderDataCellContent($model, $key, $index) { $readonly = $this->readonly; if ($readonly instanceof Closure) { $readonly = call_user_func($readonly, $model, $key, $index, $this); } if ($readonly === true) { return parent::renderDataCellContent($model, $key, $index); } $this->_editableOptions = $this->editableOptions; if (!empty($this->editableOptions) && $this->editableOptions instanceof Closure) { $this->_editableOptions = call_user_func($this->editableOptions, $model, $key, $index, $this); } if (!is_array($this->_editableOptions)) { $this->_editableOptions = []; } $options = ArrayHelper::getValue($this->_editableOptions, 'containerOptions', []); Html::addCssClass($options, $this->_css); $this->_editableOptions['containerOptions'] = $options; if ($this->grid->pjax && empty($this->_editableOptions['pjaxContainerId'])) { $this->_editableOptions['pjaxContainerId'] = $this->grid->pjaxSettings['options']['id']; } $strKey = $key; if (empty($key)) { throw new InvalidConfigException("Invalid or no primary key found for the grid data."); } elseif (!is_string($key) && !is_numeric($key)) { $strKey = serialize($key); } if ($this->attribute !== null) { $this->_editableOptions['model'] = $model; $this->_editableOptions['attribute'] = "[{$index}]{$this->attribute}"; } elseif (empty($this->_editableOptions['name']) && empty($this->_editableOptions['model']) || !empty($this->_editableOptions['model']) && empty($this->_editableOptions['attribute'])) { throw new InvalidConfigException("You must setup the 'attribute' for your EditableColumn OR set one of 'name' OR 'model' & 'attribute'" . " in 'editableOptions' (Exception at index: '{$index}', key: '{$strKey}')."); } $val = $this->getDataCellValue($model, $key, $index); if (!isset($this->_editableOptions['displayValue']) && $val !== null && $val !== '') { $this->_editableOptions['displayValue'] = parent::renderDataCellContent($model, $key, $index); } $params = Html::hiddenInput('editableIndex', $index) . Html::hiddenInput('editableKey', $strKey) . Html::hiddenInput('editableAttribute', $this->attribute); if (empty($this->_editableOptions['beforeInput'])) { $this->_editableOptions['beforeInput'] = $params; } else { $output = $this->_editableOptions['beforeInput']; $this->_editableOptions['beforeInput'] = function ($form, $widget) use($output, $params) { if ($output instanceof Closure) { return $params . call_user_func($output, $form, $widget); } else { return $params . $output; } }; } if ($this->refreshGrid) { $id = $this->grid->options['id']; $this->_view->registerJs("kvRefreshEC('{$id}','{$this->_css}');"); } return Editable::widget($this->_editableOptions); }
<?php use kartik\export\ExportMenu; use kartik\grid\GridView; use kartik\grid\DataColumn; use yii\helpers\Html; use dosamigos\datepicker\DatePicker; use app\models\Feedback; use yii\helpers\Url; $this->title = 'Обратная связь'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="feedback-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'pjax' => true, 'export' => ['fontAwesome' => true], 'panel' => ['type' => GridView::TYPE_PRIMARY], 'columns' => [['class' => 'kartik\\grid\\SerialColumn'], 'name', 'email:email', 'message:ntext', ['attribute' => 'getdata', 'value' => 'getdata', 'format' => ['date', 'php:Y-m-d H:i:s']], 'status' => ['class' => DataColumn::className(), 'attribute' => 'status', 'filter' => Html::activeDropDownList($searchModel, 'status', Feedback::$active, ['class' => 'form-control']), 'value' => function ($dataProvider) { return Feedback::$active[$dataProvider->status]; }], ['class' => 'kartik\\grid\\ActionColumn', 'template' => '{update} {delete}{link}']], 'responsive' => true, 'hover' => true, 'toolbar' => ['{export}', '{toggleData}'], 'containerOptions' => ['style' => 'overflow: auto'], 'headerRowOptions' => ['class' => 'kartik-sheet-style'], 'filterRowOptions' => ['class' => 'kartik-sheet-style']]); ?> </div>
<?php use kartik\grid\GridView; use kartik\grid\DataColumn; ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'pjax' => false, 'showPageSummary' => true, 'export' => ['fontAwesome' => true], 'columns' => ['upc_short' => ['class' => DataColumn::className(), 'attribute' => 'UPC Short', 'pageSummary' => true, 'value' => function ($dataProvider) { return $dataProvider->count_items - $dataProvider->count_items_upc; }], ['class' => 'kartik\\grid\\ActionColumn']]]);
<?php echo $form->field($model, 'name'); ?> <?php echo $form->field($model, 'object_id')->dropDownList(app\models\Object::getSelectArray()); ?> <?php echo $form->field($model, 'is_internal')->checkbox(); ?> <?php echo $form->field($model, 'hidden_group_title')->checkbox(); ?> <?php echo $form->field($model, 'sort_order'); ?> <?php BackendWidget::end(); ?> </article> </div> </section> <?php ActiveForm::end(); if (!$model->isNewRecord) { ?> <?php echo DynaGrid::widget(['options' => ['id' => 'group-grid'], 'columns' => [['class' => \kartik\grid\CheckboxColumn::className(), 'options' => ['width' => '10px']], ['class' => \kartik\grid\DataColumn::className(), 'attribute' => 'id'], ['attribute' => 'property_handler_id', 'filter' => app\models\PropertyHandler::getSelectArray(), 'value' => function ($model, $key, $index, $widget) { $array = app\models\PropertyHandler::getSelectArray(); return $array[$model->property_handler_id]; }], 'name', 'key', ['class' => \kartik\grid\BooleanColumn::className(), 'attribute' => 'has_static_values'], ['class' => \kartik\grid\BooleanColumn::className(), 'attribute' => 'has_slugs_in_values'], ['class' => \kartik\grid\BooleanColumn::className(), 'attribute' => 'is_eav'], ['class' => \kartik\grid\BooleanColumn::className(), 'attribute' => 'is_column_type_stored'], ['class' => \kartik\grid\BooleanColumn::className(), 'attribute' => 'multiple'], ['class' => ActionColumn::className(), 'buttons' => [['url' => 'edit-property', 'icon' => 'pencil', 'class' => 'btn-primary', 'label' => 'Edit'], ['url' => 'delete-property', 'icon' => 'trash-o', 'class' => 'btn-danger', 'label' => 'Delete', 'options' => ['data-action' => 'delete']]], 'url_append' => '&property_group_id=' . $model->id]], 'theme' => 'panel-default', 'gridOptions' => ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'hover' => true, 'panel' => ['heading' => Html::tag('h3', Yii::t('app', 'Properties'), ['class' => 'panel-title']), 'after' => Html::a(Icon::show('plus') . Yii::t('app', 'Add'), ['/backend/properties/edit-property', 'property_group_id' => $model->id, 'returnUrl' => \app\backend\components\Helper::getReturnUrl()], ['class' => 'btn btn-success']) . \app\backend\widgets\RemoveAllButton::widget(['url' => \yii\helpers\Url::to(['/backend/properties/remove-all-properties', 'group_id' => $model->id]), 'gridSelector' => '.grid-view', 'htmlOptions' => ['class' => 'btn btn-danger pull-right']])]]]); }