Difference between #3 and #5 of
Limit a CGridView field to some preset length.

Revision #5 has been created by le_top on Mar 24, 2013, 12:31:32 PM with the memo:

Update to handle multibyte UTF8 characters and improved tooltip encoding.
« previous (#3) next (#6) »

Changes

Title unchanged

Limit a CGridView field to some preset length.

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

CGridView, width, column, tooltip

Content changed

[...]
1) a) Create the formatter method:

```php
class YFormatter extends CFormatter {
    /* @var int The text length limit for the ShortText formatter. */
 
    public $shortTextLimit= 20;
 
/**
*
* Text formatter shortening long texts and displaying the full text
[...]
*/
public function formatShortText($value) {
        $retval=CHtml::encode($value);
 
if(strlen($value)>$this->shortTextLimit) { $retval=CHtml::tag('span',array('title'=>$retvalue),CHtml::encode(mb_substr($value,0,$this->shortTextLimit-3).'...'),Yii::app()->charset).'...'));
 
        } else {
 
            $retval=CHtml::encode($value
);
}
return $retval;
}
}
```
[...]
9 0
9 followers
Viewed: 22 897 times
Version: 1.1
Category: How-tos
Written by: le_top
Last updated by: le_top
Created on: Feb 25, 2013
Last updated: 11 years ago
Update Article

Revisions

View all history