Show
Ignore:
Timestamp:
10/06/2007 04:05:39 PM (15 months ago)
Author:
xue
Message:

Added TDataRenderer and TItemDataRenderer

Location:
trunk/framework/Web/UI/WebControls
Files:
2 added
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/framework/Web/UI/WebControls/TDataListItemRenderer.php

    r1672 r2303  
    1717 * 
    1818 * TDataListItemRenderer can be used as a convenient base class to 
    19  * define an item renderer class for {@link TDataList}. 
     19 * define an item renderer class specific for {@link TDataList}. 
    2020 * 
    21  * Because TDataListItemRenderer extends from {@link TTemplateControl}, derived child classes 
    22  * can have templates to define their presentational layout. 
     21 * TDataListItemRenderer extends {@link TItemDataRenderer} and implements 
     22 * the bubbling scheme for the OnCommand event of data list items. 
    2323 * 
    24  * TDataListItemRenderer implements {@link IItemDataRenderer} interface, 
    25  * which enables the following properties that are related with data-bound controls: 
    26  * - {@link getItemIndex ItemIndex}: zero-based index of this control in the datalist item collection. 
    27  * - {@link getItemType ItemType}: item type of this control, such as TListItemType::AlternatingItem 
    28  * - {@link getData Data}: data associated with this control 
    29  
     24 * TDataListItemRenderer also implements the {@link IStyleable} interface, 
     25 * which allows TDataList to apply CSS styles to the renders. 
     26 * 
    3027 * @author Qiang Xue <qiang.xue@gmail.com> 
    3128 * @version $Id$ 
     
    3330 * @since 3.1.0 
    3431 */ 
    35 class TDataListItemRenderer extends TTemplateControl implements IItemDataRenderer, IStyleable 
     32class TDataListItemRenderer extends TItemDataRenderer implements IStyleable 
    3633{ 
    37         /** 
    38          * index of the data item in the Items collection of TDataList 
    39          * @var integer 
    40          */ 
    41         private $_itemIndex; 
    42         /** 
    43          * type of the TDataListItem 
    44          * @var TListItemType 
    45          */ 
    46         private $_itemType; 
    47         /** 
    48          * value of the data associated with this item 
    49          * @var mixed 
    50          */ 
    51         private $_data; 
    52  
    5334        /** 
    5435         * Creates a style object to be used by the control. 
     
    9071        { 
    9172                $this->clearViewState('Style'); 
    92         } 
    93  
    94         /** 
    95          * @return TListItemType item type 
    96          */ 
    97         public function getItemType() 
    98         { 
    99                 return $this->_itemType; 
    100         } 
    101  
    102         /** 
    103          * @param TListItemType item type. 
    104          */ 
    105         public function setItemType($value) 
    106         { 
    107                 $this->_itemType=TPropertyValue::ensureEnum($value,'TListItemType'); 
    108         } 
    109  
    110         /** 
    111          * @return integer zero-based index of the item in the item collection of datalist 
    112          */ 
    113         public function getItemIndex() 
    114         { 
    115                 return $this->_itemIndex; 
    116         } 
    117  
    118         /** 
    119          * Sets the zero-based index for the item. 
    120          * If the item is not in the item collection (e.g. it is a header item), -1 should be used. 
    121          * @param integer zero-based index of the item. 
    122          */ 
    123         public function setItemIndex($value) 
    124         { 
    125                 $this->_itemIndex=TPropertyValue::ensureInteger($value); 
    126         } 
    127  
    128         /** 
    129          * @return mixed data associated with the item 
    130          */ 
    131         public function getData() 
    132         { 
    133                 return $this->_data; 
    134         } 
    135  
    136         /** 
    137          * @param mixed data to be associated with the item 
    138          */ 
    139         public function setData($value) 
    140         { 
    141                 $this->_data=$value; 
    14273        } 
    14374 
  • trunk/framework/Web/UI/WebControls/TRepeaterItemRenderer.php

    r1672 r2303  
    1212 
    1313Prado::using('System.Web.UI.WebControls.TRepeater'); 
     14Prado::using('System.Web.UI.WebControls.TItemDataRenderer'); 
    1415 
    1516/** 
     
    1718 * 
    1819 * TRepeaterItemRenderer can be used as a convenient base class to 
    19  * define an item renderer class for {@link TRepeater}. 
     20 * define an item renderer class specific for {@link TRepeater}. 
    2021 * 
    21  * Because TRepeaterItemRenderer extends from {@link TTemplateControl}, derived child classes 
    22  * can have templates to define their presentational layout. 
     22 * TRepeaterItemRenderer extends {@link TItemDataRenderer} and implements 
     23 * the bubbling scheme for the OnCommand event of repeater items. 
    2324 * 
    24  * TRepeaterItemRenderer implements {@link IItemDataRenderer} interface, 
    25  * which enables the following properties that are related with data-bound controls: 
    26  * - {@link getItemIndex ItemIndex}: zero-based index of this control in the repeater item collection. 
    27  * - {@link getItemType ItemType}: item type of this control, such as TListItemType::AlternatingItem 
    28  * - {@link getData Data}: data associated with this control 
    29  
    3025 * @author Qiang Xue <qiang.xue@gmail.com> 
    3126 * @version $Id$ 
     
    3328 * @since 3.1.0 
    3429 */ 
    35 class TRepeaterItemRenderer extends TTemplateControl implements IItemDataRenderer 
     30class TRepeaterItemRenderer extends TItemDataRenderer 
    3631{ 
    37         /** 
    38          * index of the data item in the Items collection of repeater 
    39          */ 
    40         private $_itemIndex; 
    41         /** 
    42          * type of the TRepeaterItem 
    43          * @var TListItemType 
    44          */ 
    45         private $_itemType; 
    46         /** 
    47          * data associated with this item 
    48          * @var mixed 
    49          */ 
    50         private $_data; 
    51  
    52         /** 
    53          * @return TListItemType item type 
    54          */ 
    55         public function getItemType() 
    56         { 
    57                 return $this->_itemType; 
    58         } 
    59  
    60         /** 
    61          * @param TListItemType item type. 
    62          */ 
    63         public function setItemType($value) 
    64         { 
    65                 $this->_itemType=TPropertyValue::ensureEnum($value,'TListItemType'); 
    66         } 
    67  
    68         /** 
    69          * Returns a value indicating the zero-based index of the item in the corresponding data control's item collection. 
    70          * If the item is not in the collection (e.g. it is a header item), it returns -1. 
    71          * @return integer zero-based index of the item. 
    72          */ 
    73         public function getItemIndex() 
    74         { 
    75                 return $this->_itemIndex; 
    76         } 
    77  
    78         /** 
    79          * Sets the zero-based index for the item. 
    80          * If the item is not in the item collection (e.g. it is a header item), -1 should be used. 
    81          * @param integer zero-based index of the item. 
    82          */ 
    83         public function setItemIndex($value) 
    84         { 
    85                 $this->_itemIndex=TPropertyValue::ensureInteger($value); 
    86         } 
    87  
    88         /** 
    89          * @return mixed data associated with the item 
    90          */ 
    91         public function getData() 
    92         { 
    93                 return $this->_data; 
    94         } 
    95  
    96         /** 
    97          * @param mixed data to be associated with the item 
    98          */ 
    99         public function setData($value) 
    100         { 
    101                 $this->_data=$value; 
    102         } 
    103  
    10432        /** 
    10533         * This method overrides parent's implementation by wrapping event parameter