Permalink
Browse files

New feature: allow disabled checkboxes

  • Loading branch information...
1 parent 604441c commit 51f75577664c23003b0f486d995e5d9f0fee1524 @felix-sigac felix-sigac committed Sep 10, 2012
Showing with 10 additions and 1 deletion.
  1. +10 −1 framework/zii/widgets/grid/CCheckBoxColumn.php
@@ -53,6 +53,13 @@ class CCheckBoxColumn extends CGridColumn
*/
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.
+ */
+ public $disabled=null;
+ /**
* @var array the HTML options for the data cell tags.
*/
public $htmlOptions=array('class'=>'checkbox-column');
@@ -136,7 +143,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 +210,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));
$options=$this->checkBoxHtmlOptions;
$name=$options['name'];

0 comments on commit 51f7557

Please sign in to comment.