From 3414476a698c1dbd968f53ed9d385882f060ec3c Mon Sep 17 00:00:00 2001 From: carlgmathisen <> Date: Mon, 27 Jul 2009 10:47:39 +0000 Subject: Issue #157 --- framework/Web/UI/WebControls/TCheckBoxList.php | 99 ++++++++++++++++---------- 1 file changed, 62 insertions(+), 37 deletions(-) (limited to 'framework') diff --git a/framework/Web/UI/WebControls/TCheckBoxList.php b/framework/Web/UI/WebControls/TCheckBoxList.php index 742dd18b..c7c9fc98 100644 --- a/framework/Web/UI/WebControls/TCheckBoxList.php +++ b/framework/Web/UI/WebControls/TCheckBoxList.php @@ -4,7 +4,7 @@ * * @author Qiang Xue * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft * @license http://www.pradosoft.com/license/ * @version $Id$ * @package System.Web.UI.WebControls @@ -53,7 +53,7 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont private $_isEnabled; private $_changedEventRaised=false; private $_dataChanged=false; - private $_isValid=true; + private $_isValid=true; /** * Constructor. @@ -254,6 +254,31 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont { return false; } + + /** + * @param boolean whether the control is to be enabled. + */ + public function setEnabled($value) + { + parent::setEnabled($value); + $value = !TPropertyValue::ensureBoolean($value); + // if this is an active control, + // and it's a callback, + // and we can update clientside, + // then update the 'disabled' attribute of the items. + if(($this instanceof IActiveControl) && + $this->getPage()->getIsCallBack() && + $this->getActiveControl()->canUpdateClientSide()) + { + $items = $this->getItems(); + $cs = $this->getPage()->getCallbackClient(); + $baseClientID = $this->getClientID().'_c'; + foreach($items as $index=>$item) + { + $cs->setAttribute($baseClientID.$index, 'disabled', $value); + } + } + } /** * Returns a style used for rendering items. @@ -359,16 +384,16 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont $page->registerRequiresPostData($this->_repeatedControl); } } - - /** - * Wether the list should be rendered inside a span or not - * - *@return boolean true if we need a span - */ - protected function getSpanNeeded () - { - return $this->getRepeatLayout()===TRepeatLayout::Raw; - } + + /** + * Wether the list should be rendered inside a span or not + * + *@return boolean true if we need a span + */ + protected function getSpanNeeded () + { + return $this->getRepeatLayout()===TRepeatLayout::Raw; + } /** * Renders the checkbox list control. @@ -379,11 +404,11 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont { if($this->getItemCount()>0) { - if ($needSpan=$this->getSpanNeeded()) - { - $writer->addAttribute('id', $this->getClientId()); - $writer->renderBeginTag('span'); - } + if ($needSpan=$this->getSpanNeeded()) + { + $writer->addAttribute('id', $this->getClientId()); + $writer->renderBeginTag('span'); + } $this->_isEnabled=$this->getEnabled(true); $repeatInfo=$this->getRepeatInfo(); $accessKey=$this->getAccessKey(); @@ -395,8 +420,8 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont $this->setTabIndex(0); $repeatInfo->renderRepeater($writer,$this); $this->setAccessKey($accessKey); - $this->setTabIndex($tabIndex); - if ($needSpan) + $this->setTabIndex($tabIndex); + if ($needSpan) $writer->renderEndTag(); } //checkbox skipped the client control script in addAttributesToRender @@ -429,23 +454,23 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont return $this->getSelectedValue(); } - /** - * Returns true if this control validated successfully. - * Defaults to true. - * @return bool wether this control validated successfully. - */ - public function getIsValid() - { - return $this->_isValid; - } - /** - * @param bool wether this control is valid. - */ - public function setIsValid($value) - { - $this->_isValid=TPropertyValue::ensureBoolean($value); - } - + /** + * Returns true if this control validated successfully. + * Defaults to true. + * @return bool wether this control validated successfully. + */ + public function getIsValid() + { + return $this->_isValid; + } + /** + * @param bool wether this control is valid. + */ + public function setIsValid($value) + { + $this->_isValid=TPropertyValue::ensureBoolean($value); + } + /** * Gets the name of the javascript class responsible for performing postback for this control. * This method overrides the parent implementation. @@ -468,7 +493,7 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont $options['ListName'] = $this->getUniqueID(); $options['ItemCount'] = $this->getItemCount(); return $options; - } + } } -- cgit v1.2.3