[ Index ] |
|
Code source de PRADO 3.0.6 |
1 <?php 2 /** 3 * TTemplateColumn class file 4 * 5 * @author Qiang Xue <qiang.xue@gmail.com> 6 * @link http://www.pradosoft.com/ 7 * @copyright Copyright © 2005 PradoSoft 8 * @license http://www.pradosoft.com/license/ 9 * @version $Id: TTemplateColumn.php 1397 2006-09-07 07:55:53Z wei $ 10 * @package System.Web.UI.WebControls 11 */ 12 13 /** 14 * TDataGridColumn class file 15 */ 16 Prado::using('System.Web.UI.WebControls.TDataGridColumn'); 17 18 /** 19 * TTemplateColumn class 20 * 21 * TTemplateColumn customizes the layout of controls in the column with templates. 22 * In particular, you can specify {@link setItemTemplate ItemTemplate}, 23 * {@link setEditItemTemplate EditItemTemplate}, {@link setHeaderTemplate HeaderTemplate} 24 * and {@link setFooterTemplate FooterTemplate} to customize specific 25 * type of cells in the column. 26 * 27 * Note, if {@link setHeaderTemplate HeaderTemplate} is not set, the column 28 * header will be displayed with {@link setHeaderText HeaderText}. 29 * 30 * @author Qiang Xue <qiang.xue@gmail.com> 31 * @version $Id: TTemplateColumn.php 1397 2006-09-07 07:55:53Z wei $ 32 * @package System.Web.UI.WebControls 33 * @since 3.0 34 */ 35 class TTemplateColumn extends TDataGridColumn 36 { 37 /** 38 * Various item templates 39 * @var string 40 */ 41 private $_itemTemplate=null; 42 private $_editItemTemplate=null; 43 private $_headerTemplate=null; 44 private $_footerTemplate=null; 45 46 /** 47 * @return ITemplate the edit item template 48 */ 49 public function getEditItemTemplate() 50 { 51 return $this->_editItemTemplate; 52 } 53 54 /** 55 * @param ITemplate the edit item template 56 * @throws TInvalidDataTypeException if the input is not an {@link ITemplate} or not null. 57 */ 58 public function setEditItemTemplate($value) 59 { 60 if($value instanceof ITemplate || $value===null) 61 $this->_editItemTemplate=$value; 62 else 63 throw new TInvalidDataTypeException('templatecolumn_template_required','EditItemTemplate'); 64 } 65 66 /** 67 * @return ITemplate the item template 68 */ 69 public function getItemTemplate() 70 { 71 return $this->_itemTemplate; 72 } 73 74 /** 75 * @param ITemplate the item template 76 * @throws TInvalidDataTypeException if the input is not an {@link ITemplate} or not null. 77 */ 78 public function setItemTemplate($value) 79 { 80 if($value instanceof ITemplate || $value===null) 81 $this->_itemTemplate=$value; 82 else 83 throw new TInvalidDataTypeException('templatecolumn_template_required','ItemTemplate'); 84 } 85 86 /** 87 * @return ITemplate the header template 88 */ 89 public function getHeaderTemplate() 90 { 91 return $this->_headerTemplate; 92 } 93 94 /** 95 * @param ITemplate the header template. 96 * @throws TInvalidDataTypeException if the input is not an {@link ITemplate} or not null. 97 */ 98 public function setHeaderTemplate($value) 99 { 100 if($value instanceof ITemplate || $value===null) 101 $this->_headerTemplate=$value; 102 else 103 throw new TInvalidDataTypeException('templatecolumn_template_required','HeaderTemplate'); 104 } 105 106 /** 107 * @return ITemplate the footer template 108 */ 109 public function getFooterTemplate() 110 { 111 return $this->_footerTemplate; 112 } 113 114 /** 115 * @param ITemplate the footer template 116 * @throws TInvalidDataTypeException if the input is not an {@link ITemplate} or not null. 117 */ 118 public function setFooterTemplate($value) 119 { 120 if($value instanceof ITemplate || $value===null) 121 $this->_footerTemplate=$value; 122 else 123 throw new TInvalidDataTypeException('templatecolumn_template_required','FooterTemplate'); 124 } 125 126 /** 127 * Initializes the specified cell to its initial values. 128 * This method overrides the parent implementation. 129 * It initializes the cell based on different templates 130 * (ItemTemplate, EditItemTemplate, HeaderTemplate, FooterTemplate). 131 * @param TTableCell the cell to be initialized. 132 * @param integer the index to the Columns property that the cell resides in. 133 * @param string the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem) 134 */ 135 public function initializeCell($cell,$columnIndex,$itemType) 136 { 137 parent::initializeCell($cell,$columnIndex,$itemType); 138 $template=null; 139 switch($itemType) 140 { 141 case TListItemType::Header: 142 $template=$this->_headerTemplate; 143 break; 144 case TListItemType::Footer: 145 $template=$this->_footerTemplate; 146 break; 147 case TListItemType::Item: 148 case TListItemType::AlternatingItem: 149 case TListItemType::SelectedItem: 150 $template=$this->_itemTemplate; 151 break; 152 case TListItemType::EditItem: 153 $template=$this->_editItemTemplate===null?$this->_itemTemplate:$this->_editItemTemplate; 154 break; 155 } 156 if($template!==null) 157 { 158 $cell->setText(''); 159 $cell->getControls()->clear(); 160 $template->instantiateIn($cell); 161 } 162 else if($itemType===TListItemType::Item || $itemType===TListItemType::AlternatingItem || $itemType===TListItemType::SelectedItem || $itemType===TListItemType::EditItem) 163 $cell->setText(' '); 164 } 165 } 166 167 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 21:07:04 2007 | par Balluche grâce à PHPXref 0.7 |