Submit selected grid data

Hi all,

I have a problem with a CGridView. I have same data displayed in a grid that has to be selected by the user. Data is not coming from a DB, but from the controller. In order to do that, I have used a CCheckBoxColumn. This is the view code:


<?php 

		$dataProvider = new CArrayDataProvider($inputFilesList);

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

		'id'=>'inputData',

        'dataProvider'=>$dataProvider,

		'ajaxUpdate'=>true,

        'columns'=>array(

                array(

                        'name'=>'File Name',

                	'type' => 'raw',

                	'value' => 'CHtml::encode($data["fileName"])',

                    'htmlOptions'=>array('width'=>'150')

                ),

                array(

                        'name'=>'File Path',

                	'type' => 'raw',

                	'value' => 'CHtml::encode($data["filePath"])',

                        'htmlOptions'=>array('width'=>'400')

                ),   

                array(

                	'header'=>'Readable',

                	'class'=>'CButtonColumn',

                	'template'=>'{view}',

                	'buttons' => array(

                		'view' => array(

                			'visible'=>'CHtml::encode($data["readable"])',

                        	'label'=>'Readable',

                

		                	'url'=>'Yii::app()->createUrl("/Operations/operations/view", 

		                		array("fullPath" => $data["filePath"].$data["fileName"]))',

		                					

                			'options'=>array('width'=>'350',

                			)

                		)

                	)

                ),                

                 array(

                 		'header'=>'Selected',

                        'class'=>'CCheckBoxColumn',

                 		'selectableRows'=>2,

                 		'name'=>'selected',

                        'checkBoxHtmlOptions'=>array(

                                'checked'=>'checked',

                        ),                      

                )

        ),));

        

	?>

¿How can I submit the user multiple selection?

Thank you in advance

Do I have to get the data with Javascript? How can I access to user selected data?

Please help

This is how I implemented the multiple deletion from grid view.You can use same way to collect checked entries.




// In controller defined an action DeleteAll

public function actionDeleteAll()

{

       // $_POST['campaign-grid_c0'] - is the checkbox column

       // You can find it by viewing the html source of the page

	if (isset($_POST['campaign-grid_c0']))

	{

		$del_camps = $_POST['campaign-grid_c0'];

		

		$model_camp=new Campaign;

		$model_receipiant = new Recipiants;

		

		foreach ($del_camps as $_camp_id)

		{

			$model_camp->deleteByPk($_camp_id);

			$model_receipiant->deleteAllByAttributes(array('camp_id'=>$_camp_id));

		}

					

		$this->actionAdmin();

	}

	else

	{

		Yii::app()->user->setFlash('error', 'Please select at least one record to delete.');

		$this->actionAdmin();

	}		

}


//In admin view add a button

<?php echo CHtml::button('Delete',array('name'=>'btndeleteall','class'=>'deleteall-button')); ?>




// Register javascript

Yii::app()->clientScript->registerScript('search', "

$('.search-button').click(function(){

	$('.search-form').toggle();

	return false;

});

$('.search-form form').submit(function(){

	$.fn.yiiGridView.update('campaign-grid', {

		data: $(this).serialize()

	});

	return false;

});

$('.deleteall-button').click(function(){

	

	var atLeastOneIsChecked = $('input[name=\"campaign-grid_c0[]\"]:checked').length > 0;


	if (!atLeastOneIsChecked)

	{

		alert('Please select atleast one Campaign to delete');

	}

	else if (window.confirm('Are you sure you want to delete the Campaign?'))

	{

		document.getElementById('campaign-search-form').action='index.php?r=campaign/deleteall';

		document.getElementById('campaign-search-form').submit();

	}

});

");