Grido@master
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download

Namespaces

  • Grido
    • Components
      • Actions
      • Columns
      • Filters
    • DataSources
    • PropertyAccessors
    • Translations

Classes

  • Grido\Translations\FileTranslator
 1 <?php
 2 
 3 /**
 4  * This file is part of the Grido (https://github.com/o5/grido)
 5  *
 6  * Copyright (c) 2011 Petr Bugyík (http://petr.bugyik.cz)
 7  *
 8  * For the full copyright and license information, please view
 9  * the file LICENSE.md that was distributed with this source code.
10  */
11 
12 namespace Grido\Components\Columns;
13 
14 /**
15  * Text column.
16  *
17  * @package     Grido
18  * @subpackage  Components\Columns
19  * @author      Petr Bugyík
20  */
21 class Text extends Editable
22 {
23     /** @var \Closure */
24     protected $truncate;
25 
26     /**
27      * @param string $maxLen UTF-8 encoding
28      * @param string $append UTF-8 encoding
29      * @return Column
30      */
31     public function setTruncate($maxLen, $append = "\xE2\x80\xA6")
32     {
33         $this->truncate = function($string) use ($maxLen, $append) {
34             return \Nette\Utils\Strings::truncate($string, $maxLen, $append);
35         };
36 
37         return $this;
38     }
39 
40     /**
41      * @param mixed $value
42      * @return mixed
43      */
44     protected function formatValue($value)
45     {
46         $value = parent::formatValue($value);
47 
48         if ($this->truncate) {
49             $truncate = $this->truncate;
50             $value = $truncate($value);
51         }
52 
53         return $value;
54     }
55 }
56 
Grido@master API documentation generated by ApiGen