상속: extends CDataColumn
예제 #1
1
 /**
  * Renders the data cell content.
  *
  * @param integer $row the row number (zero-based)
  * @param YdActiveRecord $data the data associated with the row
  */
 protected function renderDataCellContent($row, $data)
 {
     ob_start();
     parent::renderDataCellContent($row, $data);
     $parentContents = ob_get_clean();
     if ($data instanceof CActiveRecord) {
         $links = is_callable(array($data, 'getMenuLinks')) ? call_user_func(array($data, 'getMenuLinks')) : array();
         if ($links) {
             if (is_callable(array($data, 'getUrl'))) {
                 $this->buttonOptions['type'] = TbHtml::BUTTON_TYPE_LINK;
                 $this->buttonOptions['url'] = call_user_func(array($data, 'getUrl'));
             }
             echo '<div class="filter-container">';
             $this->buttonOptions['split'] = true;
             echo TbHtml::buttonDropdown($parentContents, $links, $this->buttonOptions);
             echo '</div>';
         } else {
             $url = is_callable(array($data, 'getUrl')) ? call_user_func(array($data, 'getUrl')) : false;
             if ($url) {
                 $this->buttonOptions['class'] = isset($this->buttonOptions['class']) ? $this->buttonOptions['class'] . ' btn' : 'btn';
                 echo TbHtml::link($parentContents, $url, $this->buttonOptions);
             } else {
                 echo TbHtml::button($parentContents, $this->buttonOptions);
             }
         }
     } else {
         echo TbHtml::button($parentContents, $this->buttonOptions);
     }
 }
예제 #2
0
 protected function renderFooterCellContent()
 {
     if (is_null($this->total)) {
         parent::renderFooterCellContent();
     }
     echo $this->totalValue ? $this->evaluateExpression($this->totalValue, array('total' => $this->total)) : $this->grid->getFormatter()->format($this->total, $this->type);
 }
 /**
  * Renders the header cell.
  */
 public function renderHeaderCell()
 {
     if ($this->grid->json) {
         $header = array('id' => $this->id);
         $content = array();
         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>';
             }
             $content['content'] = $sort->link($this->name, $label, array('class' => 'sort-link'));
         } else {
             if ($this->name !== null && $this->header === null) {
                 if ($this->grid->dataProvider instanceof CActiveDataProvider) {
                     $content['content'] = CHtml::encode($this->grid->dataProvider->model->getAttributeLabel($this->name));
                 } else {
                     $content['content'] = CHtml::encode($this->name);
                 }
             } else {
                 $content['content'] = trim($this->header) !== '' ? $this->header : $this->grid->blankDisplay;
             }
         }
         return CMap::mergeArray($header, $content);
     }
     parent::renderHeaderCell();
 }
예제 #4
0
 /**
  * widget initialization
  */
 public function init()
 {
     parent::init();
     if (empty($this->url)) {
         $this->url = Yii::app()->getRequest()->requestUri;
     }
     $this->registerClientScript();
 }
예제 #5
0
 /**
  * widget initialization
  */
 public function init()
 {
     parent::init();
     if (empty($this->url)) {
         $this->url = Yii::app()->getRequest()->requestUri;
     }
     $this->attachBehavior('ywplugin', array('class' => 'yiiwheels.behaviors.WhPlugin'));
     $this->registerClientScript();
 }
예제 #6
0
    public function init()
    {
        if (empty($this->thumbnailUrl)) {
            $this->thumbnailUrl = '$data->' . $this->name;
        }
        $this->value = '
			CHtml::link(
				CHtml::image(' . $this->thumbnailUrl . ',"", array("style"=>"' . addslashes($this->imageStyle) . '")),
				$data->' . $this->name . ',
				array("target" => "_blank")
			);';
        parent::init();
    }
 /**
  * Renders the data cell content.
  *
  * @param integer $row the row number (zero-based)
  * @param YdActiveRecord $data the data associated with the row
  */
 protected function renderDataCellContent($row, $data)
 {
     ob_start();
     parent::renderDataCellContent($row, $data);
     $parentContents = ob_get_clean();
     $links = array();
     if ($data instanceof CActiveRecord) {
         $links[] = array('label' => $parentContents, 'url' => $data->getUrl());
         $items = method_exists($data, 'getMenuLinks') ? call_user_func(array($data, 'getMenuLinks')) : array();
         if ($items) {
             $links[] = array('items' => $items);
         }
     } else {
         $links[] = $parentContents;
     }
     echo '<div class="filter-container">';
     Yii::app()->controller->widget('bootstrap.widgets.TbButtonGroup', array('buttons' => $links));
     echo '</div>';
 }
예제 #8
0
 /**
  * Initializes the column.
  */
 public function init()
 {
     parent::init();
     $this->jEditableOptions = CMap::mergeArray($this->defaultJEditableOptions, $this->jEditableOptions);
     if (!isset($this->jEditableOptions['type'])) {
         $this->jEditableOptions['type'] = 'text';
     }
     if ($this->jEditableOptions['type'] == 'select' && (!isset($this->jEditableOptions['loadurl']) && !isset($this->jEditableOptions['data']))) {
         throw new CException('zii', 'When jeditable type is "select", "loadurl" or "data" must be configured properly. The data loaded must be in "json" format.');
     }
     if (!isset($this->jEditableOptions['id'])) {
         $this->jEditableOptions['id'] = @$this->htmlOptions['id'] ? $this->htmlOptions['id'] : $this->id;
     }
     $this->event = !isset($this->jEditableOptions['event']) ? $this->jEditableOptions['event'] : 'click';
     $this->jEditableOptions['event'] = null;
     if (!$this->saveURL) {
         $this->saveURL = Yii::app()->getRequest()->requestUri;
     }
     $this->cssClass .= '-' . $this->id;
     $this->registerClientScript();
 }
예제 #9
0
    /**
     *### .renderDataCellContent()
     */
    protected function renderDataCellContent($row, $data)
    {
        $options = CMap::mergeArray($this->editable, array('model' => $data, 'attribute' => $this->name, 'parentid' => $this->grid->id));
        //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;
        }
        /** @var $widget TbEditableField */
        $widget = $this->grid->controller->createWidget('TbEditableField', $options);
        $widget->buildHtmlOptions();
        $widget->buildJsOptions();
        $widget->registerAssets();
        //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 = str_replace('\\', '_', 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__ . '#' . $this->grid->id . $selector . '-event', '
							   $("#' . $this->grid->id . '").parent().on("ajaxUpdate.yiiGridView", "#' . $this->grid->id . '", function() {' . $script . '});
            ');
            $this->_isScriptRendered = true;
        }
    }
 protected function renderHeaderCellContent()
 {
     /* TODO 
         if(yii::app()->editable->form != 'bootstrap') {
            parent::renderHeaderCellContent();
            return;
        } */
     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();
         }
     }
 }
예제 #11
0
 /**
  * need to rewrite this function as it is protected in CDataColumn: it is strange as all methods inside are public
  *
  * @param TbDataColumn $column
  * @param mixed $row
  * @param mixed $data
  *
  * @return string
  */
 private function getDataCellContent($column, $data, $row)
 {
     if ($column->value !== null) {
         $value = $column->evaluateExpression($column->value, array('data' => $data, 'row' => $row));
     } else {
         if ($column->name !== null) {
             $value = CHtml::value($data, $column->name);
         }
     }
     return !isset($value) ? $column->grid->nullDisplay : $column->grid->getFormatter()->format($value, $column->type);
 }
예제 #12
0
    /**
     *### .renderDataCellContent()
     */
    protected function renderDataCellContent($row, $data)
    {
        // #745 adding support for CArrayDataProviders only if based on a CModel array
        if (!$data instanceof CModel) {
            throw new CException('EditableColumn can be applied only to CModel based objects');
        }
        $options = CMap::mergeArray($this->editable, array('model' => $data, 'attribute' => $this->name, 'parentid' => $this->grid->id));
        //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;
        }
        /** @var $widget TbEditableField */
        $widget = $this->grid->controller->createWidget('TbEditableField', $options);
        //if editable not applied --> render original text
        if (!$widget->apply) {
            if (isset($text)) {
                echo $text;
            } else {
                parent::renderDataCellContent($row, $data);
            }
            return;
        }
        /* just add one editable call for all column cells */
        $widget->buildHtmlOptions();
        $widget->buildJsOptions();
        $widget->registerAssets();
        //can't call run() as it registers clientScript
        $widget->renderLink();
        //manually render client script (one for all cells in column)
        $selector = $widget->getSelector(false);
        if (!$this->isScriptRendered($selector)) {
            $script = $widget->registerClientScript(false);
            //use parent() as grid is totally replaced by new content
            Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $this->grid->id . '-' . $this->name . '-event', '
				$("#' . $this->grid->id . '").parent().on("ajaxUpdate.yiiGridView", "#' . $this->grid->id . '", function() {' . $script . '});
			');
        }
    }
예제 #13
0
 public function renderFilterCell()
 {
     /* TODO
        if(yii::app()->editable->form != 'bootstrap') {
            parent::renderFilterCell();
            return;
        } */
     parent::renderFilterCell();
 }