Use Ajaxlink In Cgridview

Hi

I need to use ajaxlink this my code


 ////////////// Serach for users 

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

	'id'=>'adminusers-grid',

	'dataProvider'=>$model->search(),

	'filter'=>$model,

	'columns'=>array(

		'user_id',

		'fname_ar',

		'lname_ar',

		'fa_name_ar',

     	array(

    	'name'=>'user_id',

    	'header'=>'s',

    	'filter'=>false,

   

   	'value'=> "CHtml::ajaxLink('clickMe', array('add',array('event_id'=>$event_id,'user_id'=>\$data->user_id)), array('success'=>'allFine'))",

 

    	'type'  => 'raw',

    	

   )

   ,

	

 

But link had no url ?

How to fix it ?

Dear Friend

Kindly check the following is helpful.




value'=> 'CHtml::ajaxLink("clickMe", array("add",array("event_id"=>"'.$event_id.'","user_id"=>$data->user_id)),  array(

"success"=>"js:function(data) {console.log(data)}",


))',



Regards.

Thanks seenivasan , but same result No url ?! :-[

in href the value is

href="#"

Dear Friend

I am sorry I misunderstood your requirement.

I thought You are finding difficulty in assigning url for ajax response.

CHtml::ajaxLink will not add any url to href attribute.

It assigns only "#".

It triggers ajax response by click event.

Then we have to add the href attribute to htmloptions.




value'=> 'CHtml::ajaxLink("clickMe", array("add",array("event_id"=>"'.$event_id.'","user_id"=>$data->user_id)),  array(

"success"=>"js:function(data) {console.log(data)}",

)

array("href"=>CHtml::normalizeUrl(array("event_id"=>"'.$event_id.'","user_id"=>$data->user_id))

)',



my bro , it’s return error




[b]Parse error[/b]:  syntax error, unexpected 'array' (T_ARRAY) in [b]H:\xampp\htdocs\yii\framework\base\CComponent.php(607) : eval()'d code[/b] on line [b]4[/b]



Just I simulated the scenario in my localhost .I t is working fine.




'columns'=>array(

	array(

	'name'=>'id',

	'value'=>'CHtml::ajaxLink($data->id,array("seeni/two","id"=>"'.$this->id.'"),array(

	

	"success"=>"js:function(data) {console.log(\"ok\")}"

	

	),array(

	"href"=>CHtml::normalizeUrl(array("seeni/two","id"=>"'.$this->id.'","od"=>$data->id)),

	))',

	'type'=>'raw',

	),



Just take note of single and double quotes.

Thanks , Work :)