Permalink
Browse files

Enh #1369: Added CCheckBoxColumn::disabled that accepts PHP expressio…

…n or anonymous function determining if checkbox for the row should be disabled
  • Loading branch information...
2 parents 10ea135 + ed04f69 commit 2e9fd7e0e900beaf939e9fde8a10ff533bbab1a5 @samdark samdark committed Sep 11, 2012
Showing with 12 additions and 1 deletion.
  1. +1 −0 CHANGELOG
  2. +11 −1 framework/zii/widgets/grid/CCheckBoxColumn.php
View
@@ -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)
@@ -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.
*/
@@ -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;
@@ -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));
@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.
@samdark

samdark Sep 12, 2012

Owner

Thanks. Fixed 6d21f82

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

0 comments on commit 2e9fd7e

Please sign in to comment.