Handle The Long Content In Cgridvview By Abbr Tag

Another trick for the CGridView is create abbr column. Other topics related to CGridView, can search key word "CGridView".

In most case, the client would like to show long columns in CGridView, so it makes CGridView oversize, below is a quick way to show briefly content in that columns (For example, only first 12 characters), which will save a lot of space to show more columns in one view.

Below is a screen shot, shows hot it works.



And code is here:

$this->widget('zii.widgets.grid.CGridView', array(







			'value'=>'"<abbr title=\'".$data->bid_name."\'>".substr($this->bid_name, 0, 12)."...</abbr>"',			



Now it make 60 characters into 12 characters, and when you mouse move over then it will show whole text in 60 characters.


That’s a good trick and you can read in my Wiki article how to further abstract it in a formatter:


Yes, that’s full functional converter.