How to make CGridView change to selected when link is clicked

Hi,

I have CGridView set up like this


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

    "dataProvider"=>$dataProvider,

	"selectableRows" => 1,

	'ajaxUpdate'=>true,

	'columns' => array(

		

			'question'=>

					array(

				

					'type' => 'raw',

					

					

					'value' => 'CHtml::ajaxLink(

					

						CHtml::Encode($data->question),

					 	 

						 Yii::app()->createUrl("graph/retrieveStatistics"),

						 

						 array( // ajaxOptions

						 "update"=>"#ajaxResults",

						 "type"=>"get",

						 "dataType"=>"json",

						 

						 

						 "beforeSend" => "js:function(xhr){

							 

							var appendedlUrl = this.url;

							 

							 //alert(jQuery(\"#onPremise\").attr(\'checked\'));

							 

							 if(jQuery(\"#onPremise\").attr(\'checked\') ==true){this.url = this.url+\'&onPremise=1\'};

							 if(jQuery(\"#offPremise\").attr(\'checked\') ==true){this.url = this.url+\'&offPremise=1\'};

							 if(jQuery(\"#wineTrade\").attr(\'checked\') ==true){this.url = this.url+\'&wineTrade=1\'};

							

							

							 

							 

							

							

							xhr.open(this.type, this.url);

							

							 

							 

							 

							 }",

							 

							"success" => "function( results )

										  {

												

												//alert(results);

												plotCharts(results);

												

												

										  }",

				

						//data to populate the link parameters 

    					"data" => array("qcode"=>$data->qcode,"type"=>$data->type)

						 ),

						

						array( //htmlOptions

						"href" => Yii::app()->createUrl("graph/retrieveStatistics" ),

						

  							)

						

						)',

					




						)

						

					)					 

…but when the link is clicked the row does not turn green as it does when I click the row. Is there an easy way to have the row change to selected when the link is clicked?

Thanks in advance.

Greg

with css ?

a.red:visited {color:#FF0000;}

http://www.yiiframework.com/doc/api/CGridColumn#htmlOptions-detail

edit: ah misread the question

guess there must be a js way to click the parent if the link was clicked

i’ll look it up but not sure atm

i looked it up in the code

have a look at

yii/framework/zii/widgets/assets/gridview/jquery.yiigridview.js

on line 187 there is something about selected,

there is also something about $.fn.yiiGridView.getSelection(id)

but i’d have to really dug it out on how to see how it works,

you can probably just get the row id and set it to ‘selected’ anyways i hope this points you in the right direction

Thanks for having a look, I was hoping to avoid the digging and get an easy way out ;)

I’ll post my solution when I get one.

btw, i just noticed that my rows get green even if i click a link inside it

if href=# they are just selected

if the href is an actual link and i click the back button the row is selected aswell

Hi all

I’ve created extension that allows to highlight rows by GET param.