NOTE: As of Yii version 1.1.4 the checked attribute is added to the core, so this extension is NOT NEEDED.
myCheckBoxColumn extends CCheckBoxColumn in CGridView and adds the attribute 'checked' to the column properties so that the checkbox column can be selected from row to row depending on the evaluation of this attribute.
'checked' is a string expresion that need to evaluate to true or false, if evaluates to true the checkbox will be selected otherwise will NOT be selected.
Documentation ¶
Requirements ¶
- Yii 1.0 or above
Installation ¶
- Extract the release file under
protected/components
Overview ¶
myCheckBoxColumn extends CCheckBoxColumn in CGridView and adds the attribute 'checked' to the column properties so that the checkbox column can be selected from row to row depending on the evaluation of this attribute.
'checked' is a string expresion that need to evaluate to true or false, if evaluates to true the checkbox will be selected otherwise will NOT be selected.
Usage ¶
Use it like CCheckBoxButton
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
array(
'class'=>'myCheckBoxColumn',
'checked'=>'$model->count>100',
),
'name',
'type',
),
));
?>
In the above example all rows with $model->count bigger than 100 will have the checkbox selected.
Some more examples for this attribute:
'checked'=>'true'
-
'checked'=>'$model->createdby==Yii::app()->userid'
-
'checked'=>'"checked"'
Change Log ¶
April 15, 2010 ¶
- Initial release.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.