From e050f7f5e259ffc9df018a7021e8ed946b4d614e Mon Sep 17 00:00:00 2001 From: xue <> Date: Sat, 31 Dec 2005 01:56:58 +0000 Subject: Added TDropDownList samples. --- framework/Web/UI/WebControls/TDropDownList.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'framework/Web/UI/WebControls') diff --git a/framework/Web/UI/WebControls/TDropDownList.php b/framework/Web/UI/WebControls/TDropDownList.php index 07549c6c..5e243065 100644 --- a/framework/Web/UI/WebControls/TDropDownList.php +++ b/framework/Web/UI/WebControls/TDropDownList.php @@ -10,9 +10,31 @@ class TDropDownList extends TListControl implements IPostBackDataHandler public function loadPostData($key,$values) { + //TODO: Need to doublecheck!!@! if(!$this->getEnabled(true)) return false; - // ensure DataBound??? + $selections=isset($values[$key])?$values[$key]:null; + $this->ensureDataBound(); + if($selections!==null) + { + $items=$this->getItems(); + $selection=is_array($selections)?$selections[0]:$selections; + $index=$items->findIndexByValue($selection,false); + if($this->getSelectedIndex()!==$index) + { + $this->setSelectedIndex($index); + return true; + } + else + return false; + } + else if($this->getSelectedIndex()!==-1) + { + $this->clearSelection(); + return true; + } + else + return false; } public function raisePostDataChangedEvent() -- cgit v1.2.3