CGridView Button To Update DB Value

I have a session table that holds all sessions available. I have a configuration table and one of the configurations is the current session value. I am trying to have a button in my Session CGridView for each session listed that will allow the user to click the button to set that session as the current session in the configuration table. So basically when the button is pressed it will update the configuration value for the current session.

You can customize your button column and add ajax request to it, like:




array(

   'class'=>'CButtonColumn',

   'buttons'=>array(

      'update'=>array('click'=>(...write your ajax request to update configuration here))

   )

),



If you want a more detailed help, you may need to post your code here so that people will have better understanding of your problem.

Good luck! :)

Create you action, for example: UserController.actionSetSession

and implement the ajax-call like rei told above:





'class'=>'CButtonColumn',


'buttons'=>array('view'=>

array(

    'url'=>'Yii::app()->createUrl("user/setsession", array("id"=>$data->session))',

    'options'=>array(  

    'ajax'=>array(

         'url'=>"js:$(this).attr('href')", 

            'update'=>'#id_ajaxresponse', //display a response 

           ),

     ),

     ),

   ),



Got it, thanks!