Yii Framework Forum: Handle The Long Content In Cgridvview By Abbr Tag - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Handle The Long Content In Cgridvview By Abbr Tag CGridView, Abbr Rate Topic: -----

#1 User is offline   Johnny Gan 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 203
  • Joined: 30-May 13

Posted 14 November 2013 - 03:00 PM

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.

Attached File  cgridviewabbr.png (17.28K)
Number of downloads: 6

And code is here:
$this->widget('zii.widgets.grid.CGridView', array(
...
'columns'=>array(
...
array(
			'name'=>'bid_name',
			'type'=>'html',
			'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.
0

#2 User is offline   le_top 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 440
  • Joined: 08-June 10
  • Location:France (Ile-de-France/Val d'Oise)

Posted 15 November 2013 - 02:35 AM

Hi

That's a good trick and you can read in my Wiki article how to further abstract it in a formatter:
http://www.yiiframew...-preset-length/
0

#3 User is offline   Johnny Gan 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 203
  • Joined: 30-May 13

Posted 21 November 2013 - 03:53 PM

Yes, that's full functional converter.

Thanks!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users