Yii Framework Forum: How can i add additional button in the CGridView? - Yii Framework Forum

Jump to content

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

How can i add additional button in the CGridView? Rate Topic: -----

#1 User is offline   holala 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 74
  • Joined: 23-December 09

Posted 16 January 2010 - 09:45 AM

Hi,I have a view with CGridView,default there are three button(view,update,delete) per row,I want add addtional buttons,i saw code:
array(
	'class'=>'CButtonColumn',
)

i try to add like this:
array(
	'class'=>'CButtonColumn',array(
		'buttons'=>array(
			'myButton'=>array(
				'label'=>'My Button',
				'url'=>'#',
				'imageUrl'=>'images/loading.gif',
			)
		)
	)
)

but throw a exception,please tell me how to add my buttons,thank you very much!
0

#2 User is offline   got 2 doodle 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 247
  • Joined: 12-December 08
  • Location:Beautiful Nova Scotia, Canada

Posted 16 January 2010 - 03:06 PM

'class'=>'CButtonColumn',
                        'template'=>'{view} {update} {delete} {reg}',
                        'header'=>'Actions',
                        'buttons'=>array('reg' => array(
	      'label'=>'register', 
	      'url'=>'Yii::app()->createUrl("program/register",array("participant_id"=>$data->primarykey))',


make sure that you include the 'template' code

in this example {reg} matches button 'reg' I think that this would be a requirement, I didn't try it with mismatched identifiers but it works like this, I'm not sure how to reference an image I didn't get that far yet :)

doodle
Check out myYii powered website
1

#3 User is offline   holala 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 74
  • Joined: 23-December 09

Posted 16 January 2010 - 09:21 PM

cool!
thank you very much!
0

#4 User is offline   Dariusz Męciński 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 04-March 09

Posted 17 January 2010 - 06:39 AM

ok, so how to change width of buttons column, it has 60 px setted by widget css.
0

#5 User is offline   holala 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 74
  • Joined: 23-December 09

Posted 22 January 2010 - 01:31 AM

		array(
			'class'=>'CButtonColumn',
			'template'=>'{view} {update} {reg}',
			'header'=>'Actions',
			'buttons'=>array(
				'register' => array(
					'label'=>'Register',
					'url'=>'Yii::app()->createUrl("group/register",array("group_id"=>$data->group_id))',
					'imageUrl'=>Yii::app()->request->baseUrl.'/images/register.png',
				),
			),
			'htmlOptions'=>array('width'=>100),
		),

1

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