Yii 1.1: fixed-checkbox-column

Fixes checkboxes to maintain the selected state of the entire row via CSS, necessary as of 1.1.3
2 followers

THIS EXTENSION DOES NOT WORK WITH YII 1.1.5

The bug notes for this issue indicate there will be a fix in the main branch soon. The initial target was 1.1.5, but now they moved it to 1.1.6. If you must have this patch, please use Yii v1.1.4 or lower, or wait for the official patch

If you really must have it now, message me on the forums and I will see about fixing it for you in the meantime.

This extension is necessary because of a bug in the CCheckboxColumn.

$.fn.yiiGridView.getSelection('yourGridID');

cycles through rows and returns the ids of any rows that have the css class "selected".

The problem is that the check all/uncheck all checkbox in the header of CCheckboxColumn does not maintain this class properly, so the result is that the javascript function can return the wrong rows. FixedcheckboxColumn solves this problem.

Documentation

Requirements

  • Yii 1.1 or above

Installation

  • Extract the release file under protected/extensions

Usage

See the following code example:

Yii::import('application.extensions.FixedCheckboxColumn');
 
 
<?php $this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'mygrid',
    'dataProvider'=>$model->search(),
    'selectableRows' => 2,
    'filter'=>$model,
    'columns'=>array(
        array(
            'class'=>'FixedCheckBoxColumn',
            'id' => 'rows_to_change',
        ),
        ...
        ...
    ),
));
 
 
?>
 
 
All of your javascript, such as $.fn.yiiGridView.getSelection(), is used exactly the same way. The difference is that now it always references rows whose checkboxes are checked!

Change Log

July 9, 2010

  • Initial release.

Total 1 comment

#1925 report it
derelict at 2010/10/16 05:32pm
Some issues

I think that expression

jQuery("input[name='$name'][checked=true]")

should be replaced with

jQuery("input[name='$name']:checked")

and also to use it correctly you need handler for the grid's selectionChanged event to check/uncheck checkboxes when user click on row.

Leave a comment

Please to leave your comment.

Create extension