Skip to content

Commit

Permalink
Enh #1369: Added CCheckBoxColumn::disabled that accepts PHP expressio…
Browse files Browse the repository at this point in the history
…n or anonymous function determining if checkbox for the row should be disabled
  • Loading branch information
samdark committed Sep 11, 2012
2 parents 10ea135 + ed04f69 commit 2e9fd7e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -33,6 +33,7 @@ Version 1.1.13 work in progress
- Enh #1286: CUrlValidator now supports IDN (Internationalized Domain Names), added CUrlValidator::$validateIDN property (resurtm)
- Enh #1289: Added support for column comments for MSSQL (CDbColumnSchema::$comment property) (resurtm)
- Enh #1299: Added CSRF token validation for PUT and DELETE (miraage, samdark)
- Enh #1369: Added CCheckBoxColumn::disabled that accepts PHP expression or anonymous function determining if checkbox for the row should be disabled (sucotronic)
- Enh: Fixed the check for ajaxUpdate false value in jquery.yiilistview.js as that never happens (mdomba)
- Enh: Requirements checker: added check for Oracle database (pdo_oci extension) and MSSQL (pdo_dblib, pdo_sqlsrv and pdo_mssql extensions) (resurtm)
- Enh: Added CChainedLogFilter class to allow adding multiple filters to a logroute (cebe)
Expand Down
12 changes: 11 additions & 1 deletion framework/zii/widgets/grid/CCheckBoxColumn.php
Expand Up @@ -52,6 +52,14 @@ class CCheckBoxColumn extends CGridColumn
* @since 1.1.4
*/
public $checked;
/**
* @var string a PHP expression that will be evaluated for every data cell and whose result will
* determine if checkbox for each data cell is disabled. In this expression, the variable
* <code>$row</code> the row number (zero-based); <code>$data</code> the data model for the row;
* and <code>$this</code> the column object.
* @since 1.1.13
*/
public $disabled;
/**
* @var array the HTML options for the data cell tags.
*/
Expand Down Expand Up @@ -136,7 +144,7 @@ public function init()
$cball=<<<CBALL
$(document).on('click','#{$this->id}_all',function() {
var checked=this.checked;
$("input[name='$name']").each(function() {this.checked=checked;});
$("input[name='$name']:enabled").each(function() {this.checked=checked;});
});
CBALL;
Expand Down Expand Up @@ -203,6 +211,8 @@ protected function renderDataCellContent($row,$data)
$checked = false;
if($this->checked!==null)
$checked=$this->evaluateExpression($this->checked,array('data'=>$data,'row'=>$row));
if($this->disabled!==null)
$this->checkBoxHtmlOptions['disabled']=$this->evaluateExpression($this->disabled,array('data'=>$data,'row'=>$row));

This comment has been minimized.

Copy link
@mdomba

mdomba Sep 12, 2012

Member

Two questions on this:

  • why adding this value to checkBoxHtmlOptions and then just assigning this to $options? It would be more practical to assign this directly to $options['disabled']
  • what happens if someone already set checkBoxHtmlOptions['disabled'] to any value? That value gets overwritten with the result of evaluateExpression but that is not mentioned in the doc.

This comment has been minimized.

Copy link
@samdark

samdark Sep 12, 2012

Author Member

Thanks. Fixed 6d21f82


$options=$this->checkBoxHtmlOptions;
$name=$options['name'];
Expand Down

0 comments on commit 2e9fd7e

Please sign in to comment.