diff options
5 files changed, 146 insertions, 2 deletions
diff --git a/.gitattributes b/.gitattributes index d3ff4d60..5805bbc5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -40,6 +40,8 @@ demos/quickstart/protected/pages/Configurations/Templates3.page -text  demos/quickstart/protected/pages/Construction.page -text  demos/quickstart/protected/pages/Controls/List.page -text  demos/quickstart/protected/pages/Controls/Overview.page -text +demos/quickstart/protected/pages/Controls/Samples/TDropDownList/Home.page -text +demos/quickstart/protected/pages/Controls/Samples/TDropDownList/Home.php -text  demos/quickstart/protected/pages/Controls/Samples/TLabel/Home.page -text  demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.page -text  demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.php -text diff --git a/demos/quickstart/protected/pages/Controls/List.page b/demos/quickstart/protected/pages/Controls/List.page index 4a3610fc..f305580b 100644 --- a/demos/quickstart/protected/pages/Controls/List.page +++ b/demos/quickstart/protected/pages/Controls/List.page @@ -1,14 +1,21 @@  <com:TContent ID="body" >
  <h1>List Controls</h1>
 +<p>
 +List controls covered in this section are all inherit directly or indirectly from <tt>TDataBoundControl</tt>. Therefore, you can do various databinding operations with them. More details about databinding will be given in later sections.
 +</p>
  <h2>TListBox</h2>
  <p>
 -<tt>TListBox</tt> displays a list box that allows single or multiple selection. Set the property <tt>SelectionMode</tt> as <tt>Single</tt> to make a single selection list box, and <tt>Multiple</tt> a multiple selection list box. The items in the list box are represented by the <tt>Items</tt> property. The number of rows displayed in the box is specified via the <tt>Rows</tt> property value. Some other important properties that <tt>TListBox</tt> inherits from <tt>TListControl</tt> include: <tt>Items</tt>, <tt>SelectedIndex</tt>, <tt>SelectedIndices</tt>, <tt>SelectedItem</tt>, <tt>SelectedValue</tt>, <tt>AutoPostBack</tt> and <tt>CausesValidation</tt>. Note, since <tt>TDataBoundControl</tt> is an ancestor class of <tt>TListBox</tt>, you can do various databinding operations with a list box control. More details are covered in sections about databinding.
 +<tt>TListBox</tt> displays a list box that allows single or multiple selection. Set the property <tt>SelectionMode</tt> as <tt>Single</tt> to make a single selection list box, and <tt>Multiple</tt> a multiple selection list box. The items in the list box are represented by the <tt>Items</tt> property. The number of rows displayed in the box is specified via the <tt>Rows</tt> property value. Some other important properties that <tt>TListBox</tt> inherits from <tt>TListControl</tt> include: <tt>Items</tt>, <tt>SelectedIndex</tt>, <tt>SelectedIndices</tt>, <tt>SelectedItem</tt>, <tt>SelectedValue</tt>, <tt>AutoPostBack</tt> and <tt>CausesValidation</tt>.
  </p>
  <com:RunBar PagePath="Controls.Samples.TListBox.Home" />
  <h2>TDropDownList</h2>
 +<p>
 +<tt>TDropDownList</tt> displays a dropdown list box that allows users to select a single option from a few prespecified ones. The items in the list box are represented by the <tt>Items</tt> property. The selected item can be retrieved via <tt>SelectedItem</tt> property. If <tt>AutoPostBack</tt> is true, selection change will cause page postback.
 +</p>
 +<com:RunBar PagePath="Controls.Samples.TDropDownList.Home" />
  <h2>TCheckBoxList</h2>
 diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDropDownList/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TDropDownList/Home.page new file mode 100644 index 00000000..9b82a969 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TDropDownList/Home.page @@ -0,0 +1,91 @@ +<com:TContent ID="body">
 +
 +<h1>TDropDownList Samples</h1>
 +
 +<table class="sampletable">
 +
 +<tr>
 +<td class="samplenote">
 +Dropdown list with default settings:
 +</td>
 +<td class="sampleaction">
 +<com:TDropDownList />
 +</td>
 +</tr>
 +
 +<tr>
 +<td class="samplenote">
 +Dropdown list with initial items:
 +</td>
 +<td class="sampleaction">
 +<com:TDropDownList>
 +  <com:TListItem Value="value 1" Text="item 1" />
 +  <com:TListItem Value="value 2" Text="item 2" Selected="true" />
 +  <com:TListItem Value="value 3" Text="item 3" />
 +  <com:TListItem Value="value 4" Text="item 4" />
 +</com:TDropDownList>
 +</td>
 +</tr>
 +
 +<tr>
 +<td class="samplenote">
 +List box with customized row number, color and font:
 +</td>
 +<td class="sampleaction">
 +<com:TDropDownList Rows="3" ForeColor="blue" Font.Size="14pt">
 +  <com:TListItem Value="value 1" Text="item 1" />
 +  <com:TListItem Value="value 2" Text="item 2" Selected="true" />
 +  <com:TListItem Value="value 3" Text="item 3" />
 +  <com:TListItem Value="value 4" Text="item 4" />
 +</com:TDropDownList>
 +</td>
 +</tr>
 +
 +<tr>
 +<td class="samplenote">
 +Disabled Dropdown list:
 +</td>
 +<td class="sampleaction">
 +<com:TDropDownList Enabled="false">
 +  <com:TListItem Value="value 1" Text="item 1" />
 +  <com:TListItem Value="value 2" Text="item 2" Selected="true" />
 +  <com:TListItem Value="value 3" Text="item 3" />
 +  <com:TListItem Value="value 4" Text="item 4" />
 +</com:TDropDownList>
 +</td>
 +</tr>
 +
 +<tr>
 +<td class="samplenote">
 +Auto postback Dropdown list:
 +</td>
 +<td class="sampleaction">
 +<com:TDropDownList AutoPostBack="true" SelectedIndexChanged="selectionChanged">
 +  <com:TListItem Value="value 1" Text="item 1" />
 +  <com:TListItem Value="value 2" Text="item 2" Selected="true" />
 +  <com:TListItem Value="value 3" Text="item 3" />
 +  <com:TListItem Value="value 4" Text="item 4" />
 +</com:TDropDownList>
 +<com:TLabel ID="SelectionResult" ForeColor="red" />
 +</td>
 +</tr>
 +
 +<tr>
 +<td class="samplenote">
 +Dropdown list's behavior upon postback:
 +</td>
 +<td class="sampleaction">
 +<com:TDropDownList ID="ListBox1">
 +  <com:TListItem Value="value 1" Text="item 1" />
 +  <com:TListItem Value="value 2" Text="item 2" Selected="true" />
 +  <com:TListItem Value="value 3" Text="item 3" />
 +  <com:TListItem Value="value 4" Text="item 4" />
 +</com:TDropDownList>
 +<com:TButton Text="Submit" Click="buttonClicked"/>
 +<com:TLabel ID="SelectionResult2" ForeColor="red" />
 +</td>
 +</tr>
 +
 +</table>
 +
 +</com:TContent>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDropDownList/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TDropDownList/Home.php new file mode 100644 index 00000000..3835d3c3 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TDropDownList/Home.php @@ -0,0 +1,22 @@ +<?php
 +
 +class Home extends TPage
 +{
 +	public function selectionChanged($sender,$param)
 +	{
 +		$index=$sender->SelectedIndex;
 +		$value=$sender->SelectedValue;
 +		$text=$sender->SelectedItem->Text;
 +		$this->SelectionResult->Text="Your selection is (Index: $index, Value: $value, Text: $text).";
 +	}
 +
 +	public function buttonClicked($sender,$param)
 +	{
 +		$index=$this->ListBox1->SelectedIndex;
 +		$value=$this->ListBox1->SelectedValue;
 +		$text=$this->ListBox1->SelectedItem->Text;
 +		$this->SelectionResult2->Text="Your selection is (Index: $index, Value: $value, Text: $text).";
 +	}
 +}
 +
 +?>
\ No newline at end of file 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()
  | 
