summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2006-06-21 01:02:05 +0000
committerxue <>2006-06-21 01:02:05 +0000
commit0054751b4abbb98faf378c8d0517a22be14b6c96 (patch)
treec1e5a0db5d11f168cc70bac7080dd01c7a4070af
parentc72abec23e8b4255fcaaaa0fbede3341d0149ee8 (diff)
Fixed #230.
-rw-r--r--HISTORY1
-rw-r--r--framework/Web/UI/WebControls/TDataList.php61
2 files changed, 57 insertions, 5 deletions
diff --git a/HISTORY b/HISTORY
index 3489fc71..3dd5672a 100644
--- a/HISTORY
+++ b/HISTORY
@@ -9,6 +9,7 @@ CHG: ensureChildControls() is now invoked in TControl::initRecursive (Qiang)
CHG: Postback enabled control will always disable default client-side browser action. (Qiang)
CHG: CSS and JS files in a theme are now included in page in alphabetic order (Qiang)
ENH: Ticket#206 - Added OnValidate, OnError, OnSuccess events to validators (Qiang)
+ENH: Ticket#230 - Added TDataList.EmptyTemplate property (Qiang)
ENH: Ticket#231 - Added TButton.ButtonType property to allow reset button (Qiang)
ENH: Ticket#232 - Allow <%# %> and <%= %> embedded within property values (Qiang)
diff --git a/framework/Web/UI/WebControls/TDataList.php b/framework/Web/UI/WebControls/TDataList.php
index b2bd9229..be1a9130 100644
--- a/framework/Web/UI/WebControls/TDataList.php
+++ b/framework/Web/UI/WebControls/TDataList.php
@@ -115,6 +115,7 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs
* @var Itemplate various item templates
*/
private $_itemTemplate=null;
+ private $_emptyTemplate=null;
private $_alternatingItemTemplate=null;
private $_selectedItemTemplate=null;
private $_editItemTemplate=null;
@@ -363,6 +364,39 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs
}
/**
+ * @return ITemplate the template applied when no data is bound to the datalist
+ */
+ public function getEmptyTemplate()
+ {
+ return $this->_emptyTemplate;
+ }
+
+ /**
+ * @param ITemplate the template applied when no data is bound to the datalist
+ * @throws TInvalidDataTypeException if the input is not an {@link ITemplate} or not null.
+ */
+ public function setEmptyTemplate($value)
+ {
+ if($value instanceof ITemplate || $value===null)
+ $this->_emptyTemplate=$value;
+ else
+ throw new TInvalidDataTypeException('datalist_template_required','EmptyTemplate');
+ }
+
+ /**
+ * @return TStyle the style for the content representing no data is bounded.
+ */
+ public function getEmptyStyle()
+ {
+ if(($style=$this->getViewState('EmptyStyle',null))===null)
+ {
+ $style=new TStyle;
+ $this->setViewState('EmptyStyle',$style,null);
+ }
+ return $style;
+ }
+
+ /**
* @return ITemplate the separator template
*/
public function getSeparatorTemplate()
@@ -935,6 +969,7 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs
$headerStyle=$this->getViewState('HeaderStyle',null);
$footerStyle=$this->getViewState('FooterStyle',null);
+ $emptyStyle=$this->getViewState('EmptyStyle',null);
$separatorStyle=$this->getViewState('SeparatorStyle',null);
foreach($this->getControls() as $index=>$item)
@@ -949,6 +984,10 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs
if($footerStyle)
$item->getStyle()->mergeWith($footerStyle);
break;
+ case 'Empty':
+ if($emptyStyle)
+ $item->getStyle()->mergeWith($emptyStyle);
+ break;
case 'Separator':
if($separatorStyle)
$item->getStyle()->mergeWith($separatorStyle);
@@ -1012,6 +1051,9 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs
case 'Footer':
$template=$this->_footerTemplate;
break;
+ case 'Empty':
+ $template=$this->_emptyTemplate;
+ break;
case 'Item':
$template=$this->_itemTemplate;
break;
@@ -1109,6 +1151,8 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs
if($this->_footerTemplate!==null)
$this->_footer=$this->createItemInternal(-1,'Footer',false,null);
}
+ else if($this->_emptyTemplate!==null)
+ $this->createItemInternal(-1,'Empty',false,null);
$this->clearChildState();
}
@@ -1150,6 +1194,8 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs
}
if($itemIndex>0 && $this->_footerTemplate!==null)
$this->_footer=$this->createItemInternal(-1,'Footer',true,null);
+ if($itemIndex===0 && $this->_emptyTemplate!==null)
+ $this->createItemInternal(-1,'Empty',true,null);
$this->setViewState('ItemCount',$itemIndex,0);
}
@@ -1163,8 +1209,13 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs
if($this->getHasControls())
{
$this->applyItemStyles();
- $repeatInfo=$this->getRepeatInfo();
- $repeatInfo->renderRepeater($writer,$this);
+ if($this->getItemCount()===0 && $this->_emptyTemplate!==null)
+ parent::render($writer);
+ else
+ {
+ $repeatInfo=$this->getRepeatInfo();
+ $repeatInfo->renderRepeater($writer,$this);
+ }
}
}
}
@@ -1317,7 +1368,7 @@ class TDataListItem extends TWebControl implements INamingContainer
}
/**
- * @return string item type, can be 'Header','Footer','Item','AlternatingItem','SelectedItem','EditItem','Separator','Pager'
+ * @return string item type
*/
public function getItemType()
{
@@ -1325,11 +1376,11 @@ class TDataListItem extends TWebControl implements INamingContainer
}
/**
- * @param mixed data to be associated with the item
+ * @param string item type. Valid values include 'Header','Footer','Empty','Item','AlternatingItem','SelectedItem','EditItem','Separator','Pager'.
*/
public function setItemType($value)
{
- $this->_itemType=TPropertyValue::ensureEnum($value,'Header','Footer','Item','AlternatingItem','SelectedItem','EditItem','Separator','Pager');
+ $this->_itemType=TPropertyValue::ensureEnum($value,'Header','Footer','Empty','Item','AlternatingItem','SelectedItem','EditItem','Separator','Pager');
}
/**