Prepopulate checkbox in CGridview

Hi,

I would like to know how to prepopulate few of the checkboxes in the gridview.







	// show data in grid view

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

		'id'=>'app-grid',

		'dataProvider'=>$dataProvider,	

		//'filter'=> $dataProvider,

		'selectableRows' => 2,

		'pager' => array ('header' => ''),

		'columns'=>array(

			//'id',		

			 array(

			 'id'=>'topics',

			 'class'=>'CCheckBoxColumn',				

			 

			 ),

			'id'=>'id',						

			'name' => 'name',			

			


  ) )

			

	);

?>


echo CHtml::ajaxSubmitButton('Save',array('site/namecontroller','id'=>$id,'act'=>'doActive'), array('success'=>'reloadGrid')); 




I believe that U should add and set ‘checked’ for CCheckBoxColumn.

Please look at this:

http://www.yiiframework.com/doc/api/1.1/CCheckBoxColumn#checked-detail

1 Like