/** * Render row item into template * @param Row $row * @return mixed */ public function render(Row $row) { /** * Renderer function may be used */ try { return $this->useRenderer($row); } catch (DataGridColumnRendererException $e) { /** * Do not use renderer */ } $value = parent::render($row); if (!$value && !$this->icon) { return NULL; } $a = Html::el('a')->href($this->createLink($this->grid, $this->href, $this->getItemParams($row, $this->params) + $this->parameters)); if (!empty($this->data_attributes)) { foreach ($this->data_attributes as $key => $attr_value) { $a->data($key, $attr_value); } } if ($this->open_in_new_tab) { $a->addAttributes(['target' => '_blank']); } if ($this->title) { $a->title($this->title); } if ($this->class) { $a->class($this->class); } $element = $a; if ($this->icon) { $a->addHtml(Html::el('span')->class(DataGrid::$icon_prefix . $this->icon)); if (strlen($value)) { $a->addHtml(' '); } } if ($this->isTemplateEscaped()) { $a->addText($value); } else { $a->addHtml($value); } return $element; }
/** * Render row item into template * @param Row $row * @return mixed */ public function render(Row $row) { /** * Renderer function may be used */ try { return $this->useRenderer($row); } catch (DataGridColumnRendererException $e) { /** * Do not use renderer */ } $value = parent::render($row); if (!$value && !$this->icon) { return NULL; } $a = Html::el('a')->href($this->createLink($this->href, $this->getItemParams($row, $this->params))); if (!empty($this->data_attributes)) { foreach ($this->data_attributes as $key => $value) { $a->data($key, $value); } } if ($this->title) { $a->title($this->title); } if ($this->class) { $a->class($this->class); } $element = $a; if ($this->icon) { $a->add(Html::el('span')->class(DataGrid::$icon_prefix . $this->icon)); if (strlen($value)) { $a->add(' '); } } if ($this->isTemplateEscaped()) { $a->add(htmlspecialchars((string) $value, ENT_NOQUOTES, 'UTF-8')); } else { $a->add($value); } return $element; }
/** * Render row item into template * @param Row $row * @return mixed */ public function render(Row $row) { /** * Renderer function may be used */ if ($renderer = $this->getRenderer()) { if (!$renderer->getConditionCallback()) { return call_user_func_array($renderer->getCallback(), [$row->getItem()]); } if (call_user_func_array($renderer->getConditionCallback(), [$row->getItem()])) { return call_user_func_array($renderer->getCallback(), [$row->getItem()]); } } $value = parent::render($row); $href = $this->grid->getPresenter()->link($this->href, $this->getItemParams($row)); $a = Html::el('a')->href($href)->setText($value); if ($this->title) { $a->title($this->title); } if ($this->class) { $a->class($this->class); } return $a; }