/** * Initializes the column. * * @see CDataColumn::init() */ public function init() { parent::init(); if (!isset($this->htmlCheckBoxOptions['class'])) { $this->htmlCheckBoxOptions['class'] = 'checkBoxColumn-' . $this->id; } $cs = Yii::app()->getClientScript(); $gridId = $this->grid->getId(); $script = ' jQuery(".' . $this->htmlCheckBoxOptions['class'] . '").live("click", function(e){ $.ajax({ type: "POST", dataType: "json", cache: false, url: "' . (is_array($this->actionUrl) ? CHtml::normalizeUrl($this->actionUrl) : $this->actionUrl) . '", data: { attr: "' . $this->name . '", model: "' . get_class($this->grid->filter) . '", item: $(this).attr("itemid"), checked: $(this).attr("checked")?1:0 }, success: function(data){ //alert(); $("#' . $gridId . '").yiiGridView.update("' . $gridId . '"); } }); });'; $cs->registerScript(__CLASS__ . $gridId . '#active_column-' . $this->id, $script); }
/** * Initializes the column. * * @see CDataColumn::init() */ public function init() { parent::init(); if (!isset($this->selectBoxHtmlOptions['class'])) { $this->selectBoxHtmlOptions['class'] = 'selectColumn-' . $this->id; } $cs = Yii::app()->getClientScript(); $gridId = $this->grid->getId(); $script = ' jQuery(".' . $this->selectBoxHtmlOptions['class'] . '").live("change", function(e){ e.preventDefault(); $.ajax({ type: "POST", dataType: "json", cache: false, url: "' . (is_array($this->actionUrl) ? CHtml::normalizeUrl($this->actionUrl) : $this->actionUrl) . '", data: { item: $(this).attr("itemId"), value:$("option:selected",this).val() }, success: function(data){ $("#' . $gridId . '").yiiGridView.update("' . $gridId . '"); } }); });'; $cs->registerScript(__CLASS__ . $gridId . '#active_column-' . $this->id, $script); }
protected function renderDataCellContent($row, $data) { if (!$this->isEditable($data)) { parent::renderDataCellContent($row, $data); return; } $options = CMap::mergeArray($this->editable, array('model' => $data, 'attribute' => $this->name)); //if value defined for column --> use it as element text if (strlen($this->value)) { ob_start(); parent::renderDataCellContent($row, $data); $text = ob_get_clean(); $options['text'] = $text; $options['encode'] = false; } $editable = $this->grid->controller->createWidget('TbEditableField', $options); //manually make selector non unique to match all cells in column $selector = get_class($editable->model) . '_' . $editable->attribute; $editable->htmlOptions['rel'] = $selector; $editable->renderLink(); //manually render client script (one for all cells in column) if (!$this->isScriptRendered) { $script = $editable->registerClientScript(); Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $selector . '-event', ' $("#' . $this->grid->id . '").parent().on("ajaxUpdate.yiiGridView", "#' . $this->grid->id . '", function() {' . $script . '}); '); $this->isScriptRendered = true; } }
/** * Renders the filter cell content. Here we can provide HTML options for actual filter input */ protected function renderFilterCellContent() { if (is_string($this->filter)) { echo $this->filter; } else { if ($this->filter !== false && $this->grid->filter !== null && $this->name !== null && strpos($this->name, '.') === false) { if ($this->filterInputOptions) { $filterInputOptions = $this->filterInputOptions; if (empty($filterInputOptions['id'])) { $filterInputOptions['id'] = false; } } else { $filterInputOptions = array(); } if (is_array($this->filter)) { $filterInputOptions['prompt'] = ''; echo CHtml::activeDropDownList($this->grid->filter, $this->name, $this->filter, $filterInputOptions); } else { if ($this->filter === null) { echo CHtml::activeTextField($this->grid->filter, $this->name, $filterInputOptions); } } } else { parent::renderFilterCellContent(); } } }
public function init() { parent::init(); $this->assets = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias($this->assets)) . '/publishedColumn'; $this->initVariables(); $this->grid->onRegisterScript = array($this, 'registerScript'); }
protected function renderHeaderCellContent() { $this->registerScripts(); if ($this->headerText != null) echo $this->headerText; else parent::init(); }
public function init() { if ($this->url == null) { $this->url = '/' . preg_replace('#' . Yii::app()->controller->action->id . '$#', 'sortable', Yii::app()->controller->route); } $this->registerScripts(); parent::init(); }
public function renderDataCell($row) { $this->checkCondition($row); // if (!$this->_conditionResult || $this->isSpan) // { parent::renderDataCell($row); // } }
protected function renderHeaderCellContent() { if ($this->headerText != null) { echo $this->headerText; } else { parent::renderHeaderCellContent(); } }
protected function renderDataCellContent($row, $data) { if (!$this->visible) { return $this->grid->nullDisplay; } else { return parent::renderDataCellContent($row, $data); } }
public function getDataCellContent($row) { if (method_exists(get_parent_class($this), 'getDataCellContent')) { return parent::getDataCellContent($row); } ob_start(); $this->renderDataCellContent($row, $this->grid->dataProvider->data[$row]); return ob_get_clean(); }
/** * Initialises the column. * Sets the initial value for the total. */ public function init() { parent::init(); if (is_string($this->init)) { $this->init = $this->evaluateExpression($this->init); } $this->_total = $this->init; $this->_sortDesc = !empty($this->sort) && $this->grid->dataProvider->getSort()->getDirection($this->sort); }
public function init() { parent::init(); if ($this->onButtonImageUrl === null) $this->onButtonImageUrl = Yii::app()->assetManager->publish(Yii::getPathOfAlias('application.widgets.assets.gridview').'/check_icon.png'); if ($this->offButtonImageUrl === null) $this->offButtonImageUrl = Yii::app()->assetManager->publish(Yii::getPathOfAlias('application.widgets.assets.gridview').'/uncheck_icon.png'); $this->registerClientScript(); }
/** * Renders the header cell. */ public function renderHeaderCell() { if ($this->grid->enableSorting && $this->sortable && $this->name !== null) { $direction = $this->grid->dataProvider->sort->getDirection($this->name); if ($direction !== null) { $sortCssClass = $direction ? 'headerSortDown' : 'headerSortUp'; $this->headerHtmlOptions['class'] .= ' ' . $sortCssClass; } } parent::renderHeaderCell(); }
/** * Renders the header cell content. * This method will render a link that can trigger the sorting if the column is sortable. */ protected function renderHeaderCellContent() { if ($this->name !== null && $this->header === null) { if ($this->grid->dataProvider instanceof CActiveDataProvider) { echo CHtml::encode($this->grid->dataProvider->model->getAttributeLabel($this->name)); } else { echo CHtml::encode($this->name); } } else { parent::renderHeaderCellContent(); } }
public function init() { parent::init(); //$this->visible = false;//didnt work //$this->header = ''; //if($this->name=='active'||$this->name=='created_on'||$this->name=='created_by'){ if ($this->name == 'created_on' || $this->name == 'created_by') { $this->htmlOptions = array('class' => 'debug'); $this->headerHtmlOptions = array('class' => 'debug'); $this->footerHtmlOptions = array('class' => 'debug'); $this->filterHtmlOptions = array('class' => 'debug'); } }
public function getFilterCellContent() { if (is_string($this->filter)) { return $this->filter; } elseif ($this->filter !== false && $this->grid->filter !== null && $this->name !== null && strpos($this->name, '.') === false) { if (is_array($this->filter)) { return CHtml::activeDropDownList($this->grid->filter, $this->name, $this->filter, array('id' => false, 'prompt' => '', 'class' => 'form-control')); } elseif ($this->filter === null) { return CHtml::activeTextField($this->grid->filter, $this->name, array('id' => false, 'class' => 'form-control')); } } else { return parent::getFilterCellContent(); } }
protected function renderHeaderCellContent() { if ($this->grid->enableSorting && $this->sortable && $this->name !== null) { echo $this->grid->dataProvider->getSort()->link($this->name, $this->header, array('class' => 'sort-link')); } elseif ($this->name !== null && $this->header === null) { if ($this->grid->dataProvider instanceof CActiveDataProvider) { echo CHtml::encode($this->grid->dataProvider->model->getAttributeLabel($this->name)); } else { echo CHtml::encode($this->name); } } else { parent::renderHeaderCellContent(); } }
protected function renderFilterCellContent() { if (is_string($this->filter)) { echo $this->filter; } elseif ($this->filter !== false && $this->grid->filter !== null && $this->name !== null && strpos($this->name, '.') === false) { if (is_array($this->filter)) { echo CHtml::activeDropDownList($this->grid->filter, $this->name, $this->filter, array('id' => false, 'prompt' => '')); } elseif ($this->filter === null) { echo CHtml::activeTextField($this->grid->filter, $this->name, array('id' => false, 'accesskey' => $this->accesskey)); } // 'placeholder' => '[Alt]+['.$this->accesskey.']')); } else { parent::renderFilterCellContent(); } }
protected function renderDataCellContent($row, $data) { ob_start(); parent::renderDataCellContent($row, $data); $label = ob_get_clean(); if ($this->urlExpression !== null) { $url = $this->evaluateExpression($this->urlExpression, array('data' => $data, 'row' => $row)); } else { $url = $this->url; } $options = $this->linkHtmlOptions; if (is_string($this->imageUrl)) { echo CHtml::link(CHtml::image($this->imageUrl, $label), $url, $options); } else { echo CHtml::link($label, $url, $options); } }
public function init() { parent::init(); $this->uiDateFormat = $this->uiDateFormat ? $this->uiDateFormat : "yy-mm-dd"; $this->attribute = $this->attribute ? $this->attribute : $this->name; $this->filter = Y::controller()->widget('ext.jui.FJuiDatePicker', array( 'model'=>$this->model, 'attribute'=>$this->attribute, 'language'=>'ru', 'options'=>array( 'dateFormat'=>$this->uiDateFormat ) ), true ); }
public function renderFilterCellContent() { if ($this->filter !== false && $this->grid->filter !== null && $this->name !== null && is_int(strpos($this->name, '.'))) { if (isset($this->filter['type'])) { $type = $this->filter['type']; unset($this->filter['type']); $attributes = $this->filter; // $attributes['model']=$this->getParent()->getModel(); // $attributes['attribute']=$this->name; ob_start(); $this->grid->owner->widget($type, $attributes); echo ob_get_clean(); } // else // echo $this->filter; } else { parent::renderFilterCellContent(); } }
/** * Renders the header cell content. * This method will render a link that can trigger the sorting if the column is sortable. */ protected function renderHeaderCellContent() { if ($this->grid->enableSorting && $this->sortable && $this->name !== null) { $sort = $this->grid->dataProvider->getSort(); $label = isset($this->header) ? $this->header : $sort->resolveLabel($this->name); if ($sort->resolveAttribute($this->name) !== false) { $label .= '<span class="caret"></span>'; } echo $sort->link($this->name, $label, array('class' => 'sort-link')); } else { if ($this->name !== null && $this->header === null) { if ($this->grid->dataProvider instanceof CActiveDataProvider) { echo CHtml::encode($this->grid->dataProvider->model->getAttributeLabel($this->name)); } else { echo CHtml::encode($this->name); } } else { parent::renderHeaderCellContent(); } } }
/** * Renders the filter cell content. * This method will render the {@link filter} as is if it is a string. * If {@link filter} is an array, it is assumed to be a list of options, and a dropdown selector will be rendered. * Otherwise if {@link filter} is not false, a text field is rendered. * @since 1.1.1 * This method is Copyright (c) 2008-2014 by Yii Software LLC * http://www.yiiframework.com/license/ */ protected function renderFilterCellContent() { if (is_string($this->filter)) { echo $this->filter; } elseif ($this->filter !== false && $this->grid->filter !== null && $this->name !== null && strpos($this->name, '.') === false) { /* x2modstart */ if (isset($this->filterType)) { echo $this->renderFilterCellByType(); /* x2modend */ } elseif (is_array($this->filter)) { /* x2modstart */ // removed prompt echo CHtml::activeDropDownList($this->grid->filter, $this->name, $this->filter, array('id' => false)); /* x2modend */ } elseif ($this->filter === null) { echo CHtml::activeTextField($this->grid->filter, $this->name, array('id' => false)); } } else { parent::renderFilterCellContent(); } }
/** * Renders the filter cell content. * This method will render the {@link filter} as is if it is a string. * If {@link filter} is an array, it is assumed to be a list of options, and a dropdown selector will be rendered. * Otherwise if {@link filter} is not false, a text field is rendered. * @since 1.1.1 */ protected function renderFilterCellContent() { if (is_string($this->filter)) { echo $this->filter; } else { if ($this->filter !== false && $this->grid->filter !== null && $this->name !== null && strpos($this->name, '.') === false) { if (is_array($this->filter)) { echo CHtml::activeDropDownList($this->grid->filter, $this->name, $this->filter, array('id' => false, 'prompt' => '')); } else { if ($this->filter === null) { echo CHtml::activeTextField($this->grid->filter, $this->name, array('id' => false)); } } } else { if ($this->filter !== false && $this->grid->filter !== null && $this->name !== null && strstr($this->name, '.') != false) { $relation = explode('.', $this->name); echo $this->grid->widget('Relation', array('model' => $this->grid->filter, 'relation' => $relation[0], 'fields' => $relation[1], 'hideAddButton' => true), true); } else { parent::renderFilterCellContent(); } } } }
protected function renderDataCellContent($row, $data) { $options = CMap::mergeArray($this->editable, array('model' => $data, 'attribute' => $this->name)); //if value defined for column --> use it as element text if (strlen($this->value)) { ob_start(); parent::renderDataCellContent($row, $data); $text = ob_get_clean(); $options['text'] = $text; $options['encode'] = false; } $widget = $this->grid->controller->createWidget('EditableField', $options); //if editable not applied --> render original text if (!$widget->apply) { if (isset($text)) { echo $text; } else { parent::renderDataCellContent($row, $data); } return; } //manually make selector non unique to match all cells in column $selector = get_class($widget->model) . '_' . $widget->attribute; $widget->htmlOptions['rel'] = $selector; //can't call run() as it registers clientScript $widget->renderLink(); //manually render client script (one for all cells in column) if (!$this->_isScriptRendered) { $script = $widget->registerClientScript(); //use parent() as grid is totally replaced by new content Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $selector . '-event', ' $("#' . $this->grid->id . '").parent().on("ajaxUpdate.yiiGridView", "#' . $this->grid->id . '", function() {' . $script . '}); '); $this->_isScriptRendered = true; } }
/** *### .parseColumnValue() * * @param CDataColumn $column * @param integer $row the current row number * * @return string */ protected function parseColumnValue($column, $row) { ob_start(); $column->renderDataCell($row); $value = ob_get_clean(); if ($column instanceof CDataColumn && array_key_exists($column->name, $this->extendedSummary['columns'])) { // lets get the configuration $config = $this->extendedSummary['columns'][$column->name]; // add the required column object in $config['column'] = $column; // build the summary operation object $op = $this->getSummaryOperationInstance($column->name, $config); // process the value $op->processValue($value); } return $value; }
/** * Require this overwrite to show bootstrap filter field */ public function renderFilterCell() { if (yii::app()->editable->form != EditableConfig::FORM_BOOTSTRAP) { parent::renderFilterCell(); return; } echo '<td><div class="filter-container">'; $this->renderFilterCellContent(); echo '</div></td>'; }
public function renderFilterCellContent() { switch ($this->fieldType) { case 'boolean': echo CHtml::activeDropdownList($this->grid->filter, $this->name, array('' => '- ' . Yii::t('app', 'Select') . ' -', '1' => Yii::t('app', 'Yes'), 'false' => Yii::t('app', "No")), array('class' => 'x2-minimal-select-filtercol')); break; case 'dropdown': $dropdown = Dropdowns::model()->findByPk($this->fieldModel['linkType']); if ($dropdown instanceof Dropdowns) { $options = json_decode($dropdown->options, 1); if (!$dropdown->multi) { $defaultOption = array('' => '- ' . Yii::t('app', 'Select') . ' -'); $options = is_array($options) ? array_merge($defaultOption, $options) : $defaultOption; } //$selected = isset($options[$this->grid->filter->{$this->name}]) ? //$this->grid->filter->{$this->name} : ''; echo CHtml::activeDropdownList($this->grid->filter, $this->name, $options, array('class' => 'x2-minimal-select-filtercol' . ($dropdown->multi ? ' x2-multiselect-dropdown x2-datacolumn-multiselect' : ''), 'multiple' => $dropdown->multi ? 'multiple' : '', 'data-selected-text' => $dropdown->multi ? 'option(s)' : '')); } else { parent::renderFilterCellContent(); } break; case 'visibility': echo CHtml::activeDropDownList($this->grid->filter, $this->name, array('' => '- ' . Yii::t('app', 'Select') . ' -', 1 => Yii::t('app', 'Public'), 0 => Yii::t('app', 'Private'), 2 => Yii::t('app', 'User\'s Groups')), array('class' => 'x2-minimal-select-filtercol')); break; case 'dateTime': case 'date': Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker'); $that = $this; $renderWidget = function () use($that) { echo Yii::app()->controller->widget('CJuiDateTimePicker', array('model' => $that->grid->filter, 'attribute' => $that->name, 'mode' => 'date', 'options' => array('dateFormat' => Formatter::formatDatePicker('medium')), 'htmlOptions' => array('id' => 'datePicker' . $that->name, 'class' => 'datePicker x2-gridview-filter-datepicker'), 'language' => Yii::app()->language == 'en' ? '' : Yii::app()->getLanguage()), true); }; if ($this->grid->ajax) { X2Widget::ajaxRender($renderWidget); } else { $renderWidget(); } break; default: parent::renderFilterCellContent(); } }
public function renderHeaderCell() { $this->headerHtmlOptions['width'] = '30px'; parent::renderHeaderCell(); }