renderFilterCellContent() защищенный Метод

protected renderFilterCellContent ( )
Пример #1
0
 protected function renderFilterCellContent()
 {
     $gridId = $this->grid->getId();
     $dropdownId = $gridId . '-dropdown2-filter-' . $this->attribute;
     $form = $this->grid->getForm();
     $filterModel = $this->grid->filterModel;
     $filterFields = $this->grid->filterFields;
     if ($form && $filterModel && array_key_exists($this->attribute, $filterFields)) {
         $cellContent = $form->field($filterModel, $this->attribute, $filterFields[$this->attribute]) . Html::tag('div', ButtonGroup::widget(['buttons' => [Html::button('<span class="glyphicon glyphicon-search"></span> ' . Yii::t('mozayka', 'Apply'), ['class' => 'btn btn-primary btn-sm', 'onclick' => 'jQuery(document).dropdown2(\'hide\'); jQuery(\'#' . $gridId . '\').yiiGridView(\'applyFilter\');']), Html::button('<span class="glyphicon glyphicon-ban-circle"></span> ' . Yii::t('mozayka', 'Reset'), ['class' => 'btn btn-default btn-sm', 'onclick' => 'jQuery(\'#' . $dropdownId . '\').find(\'input[type="text"], input[type="hidden"], textarea, select\').val(\'\');'])], 'options' => ['class' => 'pull-right']]), ['class' => 'clearfix']);
     } else {
         $cellContent = parent::renderFilterCellContent();
     }
     // dropdown2-panel
     if ($cellContent && $cellContent != $this->grid->emptyCell) {
         $cellContent = Html::button('<span class="glyphicon glyphicon-filter"></span>', ['title' => Yii::t('mozayka', 'Filter'), 'class' => 'btn btn-default btn-xs', 'data-dropdown2' => '#' . $dropdownId]) . Html::tag('div', Html::tag('div', $cellContent, ['class' => 'dropdown2-panel']), ['id' => $dropdownId, 'class' => 'dropdown2 dropdown2-tip' . (array_search($this, $this->grid->columns) + 1 > count($this->grid->columns) / 2 ? ' dropdown2-anchor-right' : '')]);
     }
     return $cellContent;
 }
Пример #2
0
 /**
  * Renders the filter cell content.
  * The default implementation simply renders a space.
  * This method may be overridden to customize the rendering of the filter cell (if any).
  * @return string the rendering result
  */
 protected function renderFilterCellContent()
 {
     if (is_string($this->filter)) {
         return $this->filter;
     }
     $model = $this->grid->filterModel;
     if ($this->filter !== false && $this->attribute !== null && $model->isAttributeActive($this->attribute)) {
         if ($model->hasErrors($this->attribute)) {
             Html::addCssClass($this->filterOptions, 'has-error');
             $error = ' ' . Html::error($model, $this->attribute, $this->grid->filterErrorOptions);
         } else {
             $error = '';
         }
         $filterOptions = ['=' => '=', '>' => '>', '<' => '<'];
         Html::addCssClass($this->filterInputOptions, 'date-filter-input');
         $dropDown = Html::activeDropDownList($model, $this->attribute . '_operand', $filterOptions, ['class' => 'form-control pull-left', 'style' => 'width: 32px; appearance: none; -moz-appearance: none; -webkit-appearance: none;']);
         $field = DatePicker::widget(['model' => $model, 'attribute' => $this->attribute, 'options' => $this->filterInputOptions, 'dateFormat' => 'yyyy-MM-dd']);
         return $dropDown . $field . $error;
     } else {
         return parent::renderFilterCellContent();
     }
 }
Пример #3
0
 protected function renderFilterCellContent()
 {
     if (is_string($this->filter)) {
         return $this->filter;
     }
     $model = $this->grid->filterModel;
     if ($this->filter !== false && $this->attribute !== null && $model->isAttributeActive($this->attribute)) {
         if ($model->hasErrors($this->attribute)) {
             Html::addCssClass($this->filterOptions, 'error-state');
             $error = Html::error($model, $this->attribute, $this->grid->filterErrorOptions);
         } else {
             $error = '';
         }
         if (is_array($this->filter)) {
             $options = array_merge(['prompt' => ''], $this->filterInputOptions);
             return Html::beginTag('div', ['class' => 'input-control select']) . Html::activeDropDownList($model, $this->attribute, $this->filter, $options) . ' ' . $error . Html::endTag('div');
         } else {
             return Html::beginTag('div', ['class' => 'input-control text']) . Html::activeTextInput($model, $this->attribute, $this->filterInputOptions) . ' ' . $error . Html::endTag('div');
         }
     } else {
         return parent::renderFilterCellContent();
     }
 }
Пример #4
0
 /**
  * Renders filter inputs based on the `filterType`
  *
  * @return string
  */
 protected function renderFilterCellContent()
 {
     $content = parent::renderFilterCellContent();
     $chkType = !empty($this->filterType) && $this->filterType !== GridView::FILTER_CHECKBOX && $this->filterType !== GridView::FILTER_RADIO && !class_exists($this->filterType);
     if ($this->filter === false || empty($this->filterType) || $content === $this->grid->emptyCell || $chkType) {
         return $content;
     }
     $widgetClass = $this->filterType;
     $options = ['model' => $this->grid->filterModel, 'attribute' => $this->attribute, 'options' => $this->filterInputOptions];
     if (is_array($this->filter)) {
         if ($this->filterType === GridView::FILTER_SELECT2 || $this->filterType === GridView::FILTER_TYPEAHEAD) {
             $options['data'] = $this->filter;
         }
         if ($this->filterType === GridView::FILTER_RADIO) {
             return Html::activeRadioList($this->grid->filterModel, $this->attribute, $this->filter, $this->filterInputOptions);
         }
     }
     if ($this->filterType === GridView::FILTER_CHECKBOX) {
         return Html::activeCheckbox($this->grid->filterModel, $this->attribute, $this->filterInputOptions);
     }
     $options = ArrayHelper::merge($this->filterWidgetOptions, $options);
     /** @var \kartik\base\Widget $widgetClass */
     return $widgetClass::widget($options);
 }
Пример #5
0
 /**
  * @inheritdoc
  */
 protected function renderFilterCellContent()
 {
     if (is_string($this->filter)) {
         return $this->filter;
     }
     //generates input following dbType
     $input = $this->getFilterInputByType();
     if ($input !== null) {
         return $input . $this->getFilterError();
     }
     //default
     return parent::renderFilterCellContent();
 }
Пример #6
0
 protected function renderFilterCellContent()
 {
     return parent::renderFilterCellContent();
 }
Пример #7
0
 /**
  * Renders the filter cell content.
  * The default implementation simply renders a space.
  * This method may be overridden to customize the rendering of the filter cell (if any).
  * @return string the rendering result
  */
 protected function renderFilterCellContent()
 {
     if (is_string($this->filter)) {
         return $this->filter;
     }
     $model = $this->grid->filterModel;
     if ($this->filter !== false && $model instanceof Model && $this->attribute !== null && $model->isAttributeActive($this->attribute)) {
         if ($model->hasErrors($this->attribute)) {
             Html::addCssClass($this->filterOptions, 'has-error');
             $error = ' ' . Html::error($model, $this->attribute, $this->grid->filterErrorOptions);
         } else {
             $error = '';
         }
         return Html::activeTextInput($model, $this->attribute, $this->filterInputOptions) . $error;
     } else {
         return parent::renderFilterCellContent();
     }
 }
Пример #8
0
 /**
  * @inheritdoc
  */
 protected function renderFilterCellContent()
 {
     if (is_string($this->filter)) {
         return $this->filter;
     }
     $model = $this->grid->filterModel;
     if ($this->filter !== false && $model instanceof Model && $this->attribute !== null && $model->isAttributeActive($this->attribute)) {
         if ($model->hasErrors($this->attribute)) {
             Html::addCssClass($this->filterOptions, 'has-error');
             $error = ' ' . Html::error($model, $this->attribute, $this->grid->filterErrorOptions);
         } else {
             $error = '';
         }
         if (is_array($this->filter)) {
             $filterItems = $this->filter;
             $filterItems[$this->filterAllValue] = Yii::t('yii2tech-admin', 'All records');
         } else {
             $filterItems = ['0' => Yii::t('yii2tech-admin', 'Deleted'), $this->filterAllValue => Yii::t('yii2tech-admin', 'All records')];
         }
         $options = array_merge(['prompt' => Yii::t('yii2tech-admin', 'Actual only')], $this->filterInputOptions);
         return Html::activeDropDownList($model, $this->attribute, $filterItems, $options) . $error;
     } else {
         return parent::renderFilterCellContent();
     }
 }
Пример #9
-1
 protected function renderFilterCellContent()
 {
     if (is_string($this->filter)) {
         return $this->filter;
     }
     $model = $this->grid->filterModel;
     if ($this->filter !== false && $model instanceof Model && $this->attribute !== null && $model->isAttributeActive($this->attribute)) {
         if ($model->hasErrors($this->attribute)) {
             $error = Html::error($model, $this->attribute, $this->grid->filterErrorOptions);
         } else {
             $error = '';
         }
         if (is_array($this->filter)) {
             $options = array_merge(['prompt' => ''], $this->filterDropdownOptions);
             if ($model->hasErrors($this->attribute)) {
                 Html::addCssClass($options, 'error');
             }
             return Select::widget(['model' => $model, 'attribute' => $this->attribute, 'items' => $this->filter, 'options' => $options, 'search' => true]) . ' ' . $error;
         } else {
             $options = ['class' => 'fluid'];
             if ($model->hasErrors($this->attribute)) {
                 Html::addCssClass($options, 'error');
             }
             return Elements::input(Html::activeTextInput($model, $this->attribute, $this->filterInputOptions) . $error, $options);
         }
     } else {
         return parent::renderFilterCellContent();
     }
 }
Пример #10
-1
 /**
  * @inheritdoc
  */
 protected function renderFilterCellContent()
 {
     if ($this->format == 'boolean') {
         $this->filter = [\Yii::t('app', 'No'), \Yii::t('app', 'Yes')];
     }
     if (is_string($this->filter)) {
         return $this->filter;
     }
     $model = $this->grid->filterModel;
     if ($this->filter !== false && $model instanceof Model && $this->attribute !== null && $model->isAttributeActive($this->attribute)) {
         if ($model->hasErrors($this->attribute)) {
             Html::addCssClass($this->filterOptions, 'has-error');
             $error = ' ' . Html::error($model, $this->attribute, $this->grid->filterErrorOptions);
         } else {
             $error = '';
         }
         if (is_array($this->filter)) {
             $options = array_merge(['prompt' => ''], $this->filterInputOptions);
             return Html::activeDropDownList($model, $this->attribute, $this->filter, $options) . $error;
         } else {
             return Html::activeTextInput($model, $this->attribute, $this->filterInputOptions) . $error;
         }
     } else {
         return parent::renderFilterCellContent();
     }
 }