protected function _getValue($row) { $data = parent::_getValue($row); if (!is_null($data)) { $value = $data * 1; return $value ? $value : '0'; // fixed for showing zero in grid } return $this->getColumn()->getDefault(); }
public function render($row) { $maxLenght = $this->getColumn()->getStringLimit() ? $this->getColumn()->getStringLimit() : 250; $text = parent::_getValue($row); $suffix = $this->getColumn()->getSuffix() ? $this->getColumn()->getSuffix() : '...'; if (strlen($text) > $maxLenght) { return substr($text, 0, $maxLenght) . $suffix; } else { return $text; } }
/** * Renders grid column * * @param Core_Object $row * @return mixed */ public function _getValue($row) { $format = $this->getColumn()->getFormat(); $defaultValue = $this->getColumn()->getDefault(); if (is_null($format)) { // If no format and it column not filtered specified return data as is. $data = parent::_getValue($row); $string = is_null($data) ? $defaultValue : $data; return htmlspecialchars($string); } elseif (preg_match_all($this->_variablePattern, $format, $matches)) { // Parsing of format string $formatedString = $format; foreach ($matches[0] as $matchIndex => $match) { $value = $row[$matches[1][$matchIndex]]; $formatedString = str_replace($match, $value, $formatedString); } return $formatedString; } else { return htmlspecialchars($format); } }