Customize CButtonColum

Hello averyone… i have code in CGridview like this…





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

	'id'=>'procedure-grid',

	'dataProvider'=>$procedure->search($_GET['id']),

	'selectableRows'=>2,

	'template'=>'{items}{pager}',

	'columns'=>array(

		array(

			'name'=>'code',

			'type'=>'raw',

			'value'=>'CHtml::link(CHtml::encode($data->code), $data->urlComponent)',

			'htmlOptions'=>array('width'=>'10%'),

		),

		array(

			'name'=>'name',

			'type'=>'raw',

			'value'=>'CHtml::link(CHtml::encode($data->name), $data->urlComponent)',

			'htmlOptions'=>array('width'=>''),

		),

		array(

			'name'=>'category_id',

			'type'=>'raw',

			'value'=>'CHtml::link(CHtml::encode($data->Category->name), $data->urlComponent)',

			'htmlOptions'=>array('width'=>'15%'),

		),

		array(

			'name'=>'cgs',

			'type'=>'raw',

			'value'=>'number_format(CHtml::encode($data->cgs),0)',

			'htmlOptions'=>array('width'=>'10%','style'=>'text-align:right'),

		),

		array(

			'name'=>'selling_price',

			'type'=>'raw',

			'value'=>'number_format(CHtml::encode($data->selling_price),0)',

			'htmlOptions'=>array('width'=>'10%','style'=>'text-align:right'),

		),

		array(

			'class'=>'CCheckBoxColumn',

			'selectableRows'=>'0',

			'header'=>'active',

			'checked'=>'$data->active',

		),

		array(

			'header'=>'Action',

			'class'=>'CButtonColumn',

			'template'=>'{update}{delete}',

			'buttons'=>array(

				'update'=>array(

					'label'=>'[!]',

					'url'=>'"#"',

					'click'=>'function(){

						$("#Procedure_code").val($data.code);

						$("#Procedure_name").val($data.name);

						return false;

					}',

				),

			),

			'htmlOptions'=>array('width'=>'3%','style'=>'text-align:center'),

		),

	),

)); ?>

the problem in here …





array(

			'header'=>'Action',

			'class'=>'CButtonColumn',

			'template'=>'{update}{delete}',

			'buttons'=>array(

				'update'=>array(

					'label'=>'[!]',

					'url'=>'"#"',

					'click'=>'function(){

						$("#Procedure_code").val($data.code);

						$("#Procedure_name").val($data.name);

						return false;

					}',

				),

			),

			'htmlOptions'=>array('width'=>'3%','style'=>'text-align:center'),

		),

the function click doesn’t work… anyone please help me

Iam new to yii so, i can give your suggestion to try and do it like this





$("#Procedure_code").val($data->code);

$("#Procedure_name").val($data->name);



let me know if that worked =)

It should work as suggested by dizanu83 , if it still don’t solve add some brackets:




$("#Procedure_code").val({$data->code});

$("#Procedure_name").val({$data->name});



it doesn’t work… any option else ??

This cannot work at all… you cannot get the $data variable in the client code…

to solve this you need to change the click method so that on click you first get the row clicked… and then read the appropriate column value… for example the first column for the code…

check this thread for some ideas - http://www.yiiframework.com/forum/index.php?/topic/13804-

omg… one year ago I was more clever… I am getting old

:D

zaccaria it’s like with the fitness… you just need to get back in shape… ;)

I think so :D