Difference between #2 and #4 of
Adding 'disabled' to CCheckBoxColumn and support for yiigridview.js

Changes

Title unchanged

Adding 'disabled' to CCheckBoxColumn and support for yiigridview.js

Category unchanged

Tips

Yii version unchanged

Tags changed

CCheckBoxColumn, CGridView, yiigridview.js

Content changed

I recently had to have a checkbox column in my grid view that supported the 'disabled' attribute. This was easy enough to do by extending the CCheckBoxColumn. Hwowever, I also wanted the checkbox to be selected when clicking on the table's row (supported via CGridView's selectableRows option). I discovered I had to tweak yiigridview.js so that it would not select disabled rows when clicking on it or clicking on the 'select all' checkbox.

### ECheckBoxColumn.php
[...]
### jquery.yiigridview.js
Cop
y this file andwith related files (css, img, etc) to /protected/assets/gridview/ or where ever you want it (if different, be sure to change it in the usage sceneario). I'm just going to link the whol e file here: http://pastebin.com/b5t9NdmZ

### Usage
[...]
'columns'=>array(
array(
'checked' => '('.$char[0]->activeAPIMask.' & '.$availableMask.' & $data->mask)',
 
'value'=>'$data->mask',
 
'class'=>'ext.ECheckBoxColumn',
'disabled'=>'(true/false exression (same as rowCssClassExpression)',
),
[...]
 
```php 
Your code here...
 
```
 
 
 
### Limitations 'disabled' class is hard coded into the modified JS code. For me to add a custom 'disabled' class, I would have to extend CGridView, and to me it just wasn't worth adding a small property for it to be passed into yiigridview.js.
1 0
7 followers
Viewed: 21 858 times
Version: 1.1
Category: Tips
Written by: Xgamer99
Last updated by: Maurizio Domba Cerin
Created on: Nov 9, 2012
Last updated: 12 years ago
Update Article

Revisions

View all history