yii\grid\DataColumn::renderFilterCellContent PHP Method

renderFilterCellContent() protected method

protected renderFilterCellContent ( )
    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)) {
                $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();
        }
    }

Usage Example

Exemplo n.º 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;
 }
All Usage Examples Of yii\grid\DataColumn::renderFilterCellContent