Yii Framework Forum: Display html in CGridView - Yii Framework Forum

Jump to content

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

Display html in CGridView Rate Topic: -----

#1 User is offline   itpg 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 01-April 11

Posted 09 January 2012 - 06:24 AM

How can I insert and output html tags in CGridView rows?
0

#2 User is offline   Joblo 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 565
  • Joined: 12-September 10
  • Location:Austria

Posted 09 January 2012 - 07:09 AM

Yes, you have to set the 'type' of the datacolumn to 'raw'.

See this forum topic.
1

#3 User is offline   redguy 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 771
  • Joined: 02-July 10
  • Location:Central Poland

Posted 09 January 2012 - 07:11 AM

just specify "type" of data to "raw" and it will not be escaped (look at second attribute in example below):
'columns'=>array(
	'some_attribute',
	array( 'name'=>'html_attribute', 'type'=>'raw' ),
	'another_attribute',
	array(
		'class'=>'cs.grid.CSButtonColumn',
	),
),

red
0

#4 User is offline   Roy M J 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 17-December 12
  • Location:Trivandrum, India

Posted 10 May 2013 - 04:40 AM

This should be the proper way. It has worked for me well .

'type' => 'raw',
'value'=>function($data){
  return '<div id="Div1" class="checkBox margin10 Div1"></div>';
},


Thanks

Roy M J
Homepage | Blog
0

#5 User is offline   Chayowo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 28-October 13

Posted 11 December 2013 - 05:37 AM

You may can use a php function inside the the c grid view

array('name'=>'',
      'header'=>'Type',
      'type' => 'raw',
      'value'=>'get($data)',
     ),


PHP Function

function get($data)
{
    //html tags..
}

1

Share this topic:


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

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