summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2006-07-21 18:12:36 +0000
committerxue <>2006-07-21 18:12:36 +0000
commitc67ad6b37e8f1a02d85ca5170341b22ebd6bf34b (patch)
tree5b4a9f73146f04e74679f7893d4cc31af8a37b45
parentaff2407a4507713453deb274837ab2bbf39303b2 (diff)
Fixed #263.
-rw-r--r--HISTORY1
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TDropDownList/Home.page14
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.page14
-rw-r--r--framework/Web/UI/WebControls/TDropDownList.php7
-rw-r--r--framework/Web/UI/WebControls/TListBox.php7
-rw-r--r--framework/Web/UI/WebControls/TListControl.php35
6 files changed, 75 insertions, 3 deletions
diff --git a/HISTORY b/HISTORY
index 638bd9d8..a6bae2bb 100644
--- a/HISTORY
+++ b/HISTORY
@@ -8,6 +8,7 @@ CHG: Ticket#206 - TBaseValidator.OnValidate is raised only when the validator is
ENH: Ticket#220 - TClientScripts method to import custom javascript files (Wei)
ENH: Ticket#225 - TRadioButton::getRadioButtonsInGroup() added (Wei)
ENH: Ticket#223 - Use TRequiredFieldValidator for TRadioButtons with GroupName property (Wei)
+ENH: Ticket#263 - TListBox and TDropDownList support optgroup now (Qiang)
ENH: Ticket#277 - Added TControl.CustomData property (Qiang)
ENH: Ticket#287 - TControl::broadcastEvent() may raise events now (Qiang)
ENH: Ticket#292 - Added THttpRequest::parseUrl() so that it is easier to be extended (Qiang)
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDropDownList/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TDropDownList/Home.page
index 90dc4a3c..1b0b82d9 100644
--- a/demos/quickstart/protected/pages/Controls/Samples/TDropDownList/Home.page
+++ b/demos/quickstart/protected/pages/Controls/Samples/TDropDownList/Home.page
@@ -184,6 +184,20 @@ Dropdown list causing validation:
</td>
</tr>
+<tr>
+<td class="samplenote">
+Dropdown list with option groups:
+</td>
+<td class="sampleaction">
+<com:TDropDownList>
+ <com:TListItem Value="value 1" Text="item 1" Attributes.Group="group 1"/>
+ <com:TListItem Value="value 2" Text="item 2" Attributes.Group="group 1"/>
+ <com:TListItem Value="value 3" Text="item 3" Attributes.Group="group 2"/>
+ <com:TListItem Value="value 4" Text="item 4" Attributes.Group="group 2"/>
+</com:TDropDownList>
+</td>
+</tr>
+
</table>
</com:TContent> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.page
index 9f9bf162..7b729588 100644
--- a/demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.page
+++ b/demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.page
@@ -255,6 +255,20 @@ List box causing validation:
</td>
</tr>
+<tr>
+<td class="samplenote">
+List box with option groups:
+</td>
+<td class="sampleaction">
+<com:TListBox>
+ <com:TListItem Value="value 1" Text="item 1" Attributes.Group="group 1"/>
+ <com:TListItem Value="value 2" Text="item 2" Attributes.Group="group 1"/>
+ <com:TListItem Value="value 3" Text="item 3" Attributes.Group="group 2"/>
+ <com:TListItem Value="value 4" Text="item 4" Attributes.Group="group 2"/>
+</com:TListBox>
+</td>
+</tr>
+
</table>
</com:TContent> \ No newline at end of file
diff --git a/framework/Web/UI/WebControls/TDropDownList.php b/framework/Web/UI/WebControls/TDropDownList.php
index 860fe69c..04f3780c 100644
--- a/framework/Web/UI/WebControls/TDropDownList.php
+++ b/framework/Web/UI/WebControls/TDropDownList.php
@@ -21,6 +21,13 @@ Prado::using('System.Web.UI.WebControls.TListControl');
* TDropDownList displays a dropdown list on a Web page.
* It inherits all properties and events from {@link TListControl}.
*
+ * Since v3.0.3, TDropDownList starts to support optgroup. To specify an option group for
+ * a list item, set a Group attribute with it,
+ * <code>
+ * $listitem->Attributes->Group="Group Name";
+ * // or <com:TListItem Attributes.Group="Group Name" .../> in template
+ * </code>
+ *
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
* @package System.Web.UI.WebControls
diff --git a/framework/Web/UI/WebControls/TListBox.php b/framework/Web/UI/WebControls/TListBox.php
index 972ebbcb..79b73fb6 100644
--- a/framework/Web/UI/WebControls/TListBox.php
+++ b/framework/Web/UI/WebControls/TListBox.php
@@ -24,6 +24,13 @@ Prado::using('System.Web.UI.WebControls.TListControl');
* The property {@link setRows Rows} specifies how many rows of options are visible
* at a time. See {@link TListControl} for inherited properties.
*
+ * Since v3.0.3, TListBox starts to support optgroup. To specify an option group for
+ * a list item, set a Group attribute with it,
+ * <code>
+ * $listitem->Attributes->Group="Group Name";
+ * // or <com:TListItem Attributes.Group="Group Name" .../> in template
+ * </code>
+ *
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
* @package System.Web.UI.WebControls
diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php
index 7cdfc727..d5949dde 100644
--- a/framework/Web/UI/WebControls/TListControl.php
+++ b/framework/Web/UI/WebControls/TListControl.php
@@ -621,24 +621,53 @@ abstract class TListControl extends TDataBoundControl
if($this->_items)
{
$writer->writeLine();
+ $previousGroup=null;
foreach($this->_items as $item)
{
if($item->getEnabled())
{
- if($item->getSelected())
- $writer->addAttribute('selected','selected');
- $writer->addAttribute('value',$item->getValue());
if($item->getHasAttributes())
{
+ $group=$item->getAttributes()->remove('Group');
+ if($group!==$previousGroup)
+ {
+ if($previousGroup!==null)
+ {
+ $writer->renderEndTag();
+ $writer->writeLine();
+ $previousGroup=null;
+ }
+ if($group!==null)
+ {
+ $writer->addAttribute('label',$group);
+ $writer->renderBeginTag('optgroup');
+ $writer->writeLine();
+ $previousGroup=$group;
+ }
+ }
foreach($item->getAttributes() as $name=>$value)
$writer->addAttribute($name,$value);
}
+ else if($previousGroup!==null)
+ {
+ $writer->renderEndTag();
+ $writer->writeLine();
+ $previousGroup=null;
+ }
+ if($item->getSelected())
+ $writer->addAttribute('selected','selected');
+ $writer->addAttribute('value',$item->getValue());
$writer->renderBeginTag('option');
$writer->write(THttpUtility::htmlEncode($item->getText()));
$writer->renderEndTag();
$writer->writeLine();
}
}
+ if($previousGroup!==null)
+ {
+ $writer->renderEndTag();
+ $writer->writeLine();
+ }
}
}