Select All Checkbox

In the List view of yii, i want to show a checkbox for each data item. At the top of have a checkbox. When check the top checkbox i want to check all checkbox in list. How it done in yii? Whats the script for this.?


<?php echo CHtml::form(); ?>

<?php echo CHtml::checkBox("main",false,array('value'=>'','id'=>'check1'));  ?>

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



        'template' => '{items}{pager}',

)); ?>

<?php echo CHtml::endForm(); ?>



<?php echo CHtml::checkBox("abc[]",false,array('value'=>$data->message_id,'id'=>'sub'));  ?>

<?php echo $data->body; ?>


Need the client script.



$(function () {

&#036;('#check1').click(function () {

    &#036;(this).parents('fieldset:eq(0)').find(':checkbox').attr('checked', this.checked);




in CGirdView the selectableRows=>2 allows you to check multiple boxes and it puts a check all box at the top.

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




		array('header' => 'Roles',

				'value' => '$data->name',



		array ('class'=>'CCheckBoxColumn',



			'htmlOptions'=>array('width:15; text-align: center;'),







I was looking for the solution to this problem and the solution posted by haymps saved me . Thank you !!