How to make CGridView change to selected when link is clicked


I have CGridView set up like this

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


	"selectableRows" => 1,


	'columns' => array(





					'type' => 'raw',



					'value' => 'CHtml::ajaxLink(






						 array( // ajaxOptions






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


							var appendedlUrl = this.url;




							 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\'};






						, this.url);







							"success" => "function( 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.


with css ? {color:#FF0000;}

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


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.