From a55994488789e9c481aab5e3e49b15bd9718afc1 Mon Sep 17 00:00:00 2001 From: xue <> Date: Sun, 3 Sep 2006 12:27:38 +0000 Subject: Fixed #357. --- HISTORY | 1 + framework/Web/UI/WebControls/TListControl.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/HISTORY b/HISTORY index 7652c49a..18f07e0b 100644 --- a/HISTORY +++ b/HISTORY @@ -5,6 +5,7 @@ BUG: Fixed a typo in TControl::setCustomData() (Qiang) ENH: Ticket#336 - Speed up TSqliteCache with LIMIT SQL clause (Qiang) ENH: Ticket#348 - Added THead.ShortcutIcon (Qiang) ENH: Ticket#349 - Derived control classes now show trace logs when databinding (Qiang) +ENH: Ticket#357 - Added TListControl.DataGroupField to allow setting optgroup via databinding (Qiang) ENH: TListControl.SelectedValues and SelectedIndices can now be set before databinding (Qiang) ENH: Upgrade Scriptaculous javascript library to 1.6.2 (Wei) ENH: Uses uncompressed javascript in debug mode. (Wei) diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php index 1c65259c..856205b2 100644 --- a/framework/Web/UI/WebControls/TListControl.php +++ b/framework/Web/UI/WebControls/TListControl.php @@ -186,6 +186,7 @@ abstract class TListControl extends TDataBoundControl if($valueField==='') $valueField=1; $textFormat=$this->getDataTextFormatString(); + $groupField=$this->getDataGroupField(); foreach($data as $key=>$object) { $item=$items->createListItem(); @@ -194,6 +195,8 @@ abstract class TListControl extends TDataBoundControl $text=TDataFieldAccessor::getDataFieldValue($object,$textField); $value=TDataFieldAccessor::getDataFieldValue($object,$valueField); $item->setValue($value); + if($groupField!=='') + $item->setAttribute('Group',TDataFieldAccessor::getDataFieldValue($object,$groupField)); } else { @@ -386,6 +389,22 @@ abstract class TListControl extends TDataBoundControl $this->setViewState('DataValueField',$value,''); } + /** + * @return string the field of the data source that provides the label of the list item groups + */ + public function getDataGroupField() + { + return $this->getViewState('DataGroupField',''); + } + + /** + * @param string the field of the data source that provides the label of the list item groups + */ + public function setDataGroupField($value) + { + $this->setViewState('DataGroupField',$value,''); + } + /** * @return integer the number of items in the list control */ -- cgit v1.2.3