CCheckBoxColumn not checked after ajax call

Hi all,

I have a small issue with a CCheckBoxColumn in a CGridView.

I created a CGridview and use a CCheckBoxColumn to select a row. I need to store in a cookie the list of row selected ( I also use pagination), so I implemented a ajax call like this :

In the controller I have




public function actionaddQuestion()

	{

echo "Test OK";

}



in the view I have :




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

    'id'=>'tblquizz-grid',

    'dataProvider'=>$modelQuestion->listquestion(),

    'columns'=>array(

    	   array(

                'class'=>'CCheckBoxColumn',

 		'id'=>"cid_".$modelQuestion->INUMQUEST,

 		'selectableRows' => 2,

 						

 		'checkBoxHtmlOptions' => array( "ajax" => 

                                                array("type"=>"POST", 

						       "url"=>CController::createUrl("tblquizz/addQuestion"),

							"update"=>"#section_info", 

			        			),

 		

 						)

 						

 		 

                ),



So when I click on the checkbox, the ajax method is call and I can read the post value.

But Afterthat the checkbox is not checked. If I click again, I call again the ajax method but checkbox still not checked.

So please tell me in that case how I can have the checkbox checked. Should we implement in a different way ?

I’m not sure, but could it be that the view where the checkbox is in, get refreshed after the ajax request, therefore resetting it’s original state?

i have the same issue here. But still not get any stable solution for it.

A small issue with checkbox.But taking lot of time to get it resolved.Any body can suggest me a good solution for it. I have also post my problem on This link

Any help from an expert would be appreciated.

Thanks in Advance.

Jayant

You can use ‘name’, ‘value’ or ‘checked’ property of CCheckBoxColumn to set the initial status of checkboxes.

http://www.yiiframework.com/doc/api/1.1/CCheckBoxColumn

Doesn’t work yet. :(

You’ll have to read the value of the cookie in the ‘checked’ property to check the box:




'columns'=>array(

           array(

                'class'=>'CCheckBoxColumn',

                'id'=>"cid_".$modelQuestion->INUMQUEST,

                'selectableRows' => 2,

                                                

                'checkBoxHtmlOptions' => array( "ajax" => 

                                                array("type"=>"POST", 

                                                       "url"=>CController::createUrl("tblquizz/addQuestion"),

                                                        "update"=>"#section_info", 

                                                        ),

                                                ),

                'checked'=>(isset(Yii::app()->request->cookies['cookie_name'])) ? 

                                                Yii::app()->request->cookies['cookie_name']->value : 0;

                                                

                 

                ),