diff options
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | UPGRADE | 4 | ||||
-rw-r--r-- | demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample3.page | 4 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TDropDownListColumn.php | 72 |
4 files changed, 59 insertions, 22 deletions
@@ -5,6 +5,7 @@ ENH: Ticket#361 - Introduced include template tag that supports including extern ENH: Ticket#366 - white spaces are now allowed around attribute names in template (Qiang) ENH: Ticket#378 - PRADO applications can now run in command line (Qiang) ENH: Ticket#379 - TAuthorizationRule performance enhancement (Qiang) +ENH: Ticket#394 - Enhancing TDropDownListColumn to allow specifying both text and value (Qiang) ENH: Easier to customize the TDatePicker using CssClass (Wei) ENH: Added an interactive PHP shell, usage: "prado-cli.php shell" (Wei) NEW: TLiteralColumn (Qiang) @@ -17,7 +17,9 @@ Upgrading from v3.0.4 ---------------------
- TFileUpload::saveAs() will return false instead of raising an exception
if it encounters any error.
-
+- TDropDownListColumn.DataField is renamed to DataTextField and
+ DataFormatString is renamed to DataTextFormatString.
+ A new property named DataValueField is added.
Upgrading from v3.0.3
---------------------
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample3.page b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample3.page index 5fb19c6f..28b6288e 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample3.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample3.page @@ -53,9 +53,9 @@ <com:TDropDownListColumn
ID="RatingColumn"
HeaderText="Rating"
- DataField="rating"
+ DataTextField="rating"
>
- <prop:DataFormatString><img src="images/star%s.gif" alt="" /></prop:DataFormatString>
+ <prop:DataTextFormatString><img src="images/star%s.gif" alt="" /></prop:DataTextFormatString>
<com:TListItem Value="1" />
<com:TListItem Value="2" />
<com:TListItem Value="3" />
diff --git a/framework/Web/UI/WebControls/TDropDownListColumn.php b/framework/Web/UI/WebControls/TDropDownListColumn.php index dbc20f7a..384a3701 100644 --- a/framework/Web/UI/WebControls/TDropDownListColumn.php +++ b/framework/Web/UI/WebControls/TDropDownListColumn.php @@ -18,11 +18,13 @@ Prado::using('System.Web.UI.WebControls.TDropDownList'); *
* TDropDownListColumn represents a column that is bound to a field in a data source.
* The cells in the column will be displayed using the data indexed by
- * {@link setDataField DataField}. You can customize the display by
- * setting {@link setDataFormatString DataFormatString}.
+ * {@link setDataTextField DataTextField}. You can customize the display by
+ * setting {@link setDataTextFormatString DataTextFormatString}.
*
* If {@link setReadOnly ReadOnly} is false, TDropDownListColumn will display cells in edit mode
* with dropdown lists. Otherwise, a static text is displayed.
+ * The currently selected dropndown list item is specified by the data indexed with
+ * {@link setDataValueField DataValueField}.
*
* There are two approaches to specify the list items available for selection.
* The first approach uses template syntax as follows,
@@ -107,35 +109,57 @@ class TDropDownListColumn extends TDataGridColumn }
/**
- * @return string the field name from the data source to bind to the column
+ * @return string the field of the data source that provides the text content of the column.
*/
- public function getDataField()
+ public function getDataTextField()
{
- return $this->getViewState('DataField','');
+ return $this->getViewState('DataTextField','');
}
/**
- * @param string the field name from the data source to bind to the column
+ * Sets the field of the data source that provides the text content of the column.
+ * If this is not set, the data specified via {@link getDataValueField DataValueField}
+ * will be displayed in the column.
+ * @param string the field of the data source that provides the text content of the column.
*/
- public function setDataField($value)
+ public function setDataTextField($value)
{
- $this->setViewState('DataField',$value,'');
+ $this->setViewState('DataTextField',$value,'');
}
/**
* @return string the formatting string used to control how the bound data will be displayed.
*/
- public function getDataFormatString()
+ public function getDataTextFormatString()
{
- return $this->getViewState('DataFormatString','');
+ return $this->getViewState('DataTextFormatString','');
}
/**
* @param string the formatting string used to control how the bound data will be displayed.
*/
- public function setDataFormatString($value)
+ public function setDataTextFormatString($value)
{
- $this->setViewState('DataFormatString',$value,'');
+ $this->setViewState('DataTextFormatString',$value,'');
+ }
+
+ /**
+ * @return string the field of the data source that provides the key selecting an item in dropdown list.
+ */
+ public function getDataValueField()
+ {
+ return $this->getViewState('DataValueField','');
+ }
+
+ /**
+ * Sets the field of the data source that provides the key selecting an item in dropdown list.
+ * If this is not present, the data specified via {@link getDataTextField DataTextField} (without
+ * applying the formatting string) will be used for selection, instead.
+ * @param string the field of the data source that provides the key selecting an item in dropdown list.
+ */
+ public function setDataValueField($value)
+ {
+ $this->setViewState('DataValueField',$value,'');
}
/**
@@ -257,7 +281,7 @@ class TDropDownListColumn extends TDataGridColumn case TListItemType::Item:
case TListItemType::AlternatingItem:
case TListItemType::SelectedItem:
- if($this->getDataField()!=='')
+ if($this->getDataTextField()!=='' || $this->getDataValueField()!=='')
$cell->attachEventHandler('OnDataBinding',array($this,'dataBindColumn'));
break;
}
@@ -272,14 +296,24 @@ class TDropDownListColumn extends TDataGridColumn {
$item=$sender->getNamingContainer();
$data=$item->getDataItem();
- if(($field=$this->getDataField())!=='')
- $data=$this->getDataFieldValue($data,$field);
- $formatString=$this->getDataFormatString();
- $value=$this->formatDataValue($formatString,$data);
+ if(($valueField=$this->getDataValueField())!=='')
+ $value=$this->getDataFieldValue($data,$valueField);
+ else
+ $value='';
+ if(($textField=$this->getDataTextField())!=='')
+ {
+ $text=$this->getDataFieldValue($data,$textField);
+ if($valueField==='')
+ $value=$text;
+ $formatString=$this->getDataTextFormatString();
+ $text=$this->formatDataValue($formatString,$text);
+ }
+ else
+ $text=$value;
if($sender instanceof TTableCell)
- $sender->setText($value);
+ $sender->setText($text);
else if($sender instanceof TDropDownList)
- $sender->setSelectedValue($data);
+ $sender->setSelectedValue($value);
}
}
|