Yii 1.1: mycheckboxcolumn

extension to make CCheckBoxColumn selected by default, depending from row to row
3 followers

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.

Be the first person to leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: Other Open Source License
  • Developed by: Maurizio Domba Cerin
  • Category: User Interface
  • Votes: +3
  • Downloaded: 603 times
  • Created on: Apr 15, 2010
  • Last updated: Oct 18, 2010