Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

New feature: allow disabled checkboxes #1369

Merged
merged 2 commits into from

4 participants

@sucotronic

This modification enables the CCheckBoxColumn to disable some columns, and avoid to get them selected when clicking the upper checkbox (to select/deselect all).

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;

Change to
public $disabled;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
+ */

Add
@since 1.1.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@samdark samdark was assigned
@samdark samdark referenced this pull request from a commit
@samdark samdark Enh #1369: Added CCheckBoxColumn::disabled that accepts PHP expressio…
…n or anonymous function determining if checkbox for the row should be disabled
2e9fd7e
@samdark samdark merged commit ed04f69 into from
@samdark
Owner

Thanks for working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 10, 2012
  1. @felix-sigac
  2. @sucotronic

    Yii style

    sucotronic authored
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 1 deletion.
  1. +11 −1 framework/zii/widgets/grid/CCheckBoxColumn.php
View
12 framework/zii/widgets/grid/CCheckBoxColumn.php
@@ -53,6 +53,14 @@ 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.
+ * @since 1.1.13
+ */
+ public $disabled;
+ /**
* @var array the HTML options for the data cell tags.
*/
public $htmlOptions=array('class'=>'checkbox-column');
@@ -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));
$options=$this->checkBoxHtmlOptions;
$name=$options['name'];
Something went wrong with that request. Please try again.