Check and Uncheck All Checkboxes

hi all,

  I need to implement select all and unselect all for the list of checkboxes in a page.

I am able to display the data with chechboxes. Now i want the user to be provided with the provision of at a time selecting all checkboxes and deselection.

the code is





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

	'id'=>'flatchargesmapping-grid',

'dataProvider' =>$dataProvider,


'columns' => array(

    array(

      'name' =>'',

      'value' => 'CHtml::checkBox("id[]",null,array("value"=>$data->id,"id"=>"rid_".$data->id))',

      'type'=>'raw',

      'htmlOptions' => array('width'=>5),

      'visible' => !Yii::app()->user->isGuest,

    ),


    'id',

    'flat_number',

    'Charge_code',

    array(

        'class' => 'CButtonColumn',

        'viewButtonUrl' => 'Yii::app()->createUrl("Flatchargesmapping/view",array("id"=>$data["id"]))',

        'template'=>'{view}',

    ),

),

 ));?>

help me please.

Can I suggest you use the CCheckBoxColumn - http://www.yiiframework.com/doc/api/1.1/CCheckBoxColumn? It was made for this situation.

Don’t forget to set the ‘selectableRows’ property to the number of rows you have in your table, otherwise the ‘select all’/‘deselect all’ will not be available.