[ Index ] |
|
Code source de PRADO 3.0.6 |
1 <?php 2 /** 3 * TDropDownList 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: TDropDownList.php 1397 2006-09-07 07:55:53Z wei $ 10 * @package System.Web.UI.WebControls 11 */ 12 13 /** 14 * Includes TListControl class 15 */ 16 Prado::using('System.Web.UI.WebControls.TListControl'); 17 18 /** 19 * TDropDownList class 20 * 21 * TDropDownList displays a dropdown list on a Web page. 22 * It inherits all properties and events from {@link TListControl}. 23 * 24 * Since v3.0.3, TDropDownList starts to support optgroup. To specify an option group for 25 * a list item, set a Group attribute with it, 26 * <code> 27 * $listitem->Attributes->Group="Group Name"; 28 * // or <com:TListItem Attributes.Group="Group Name" .../> in template 29 * </code> 30 * 31 * @author Qiang Xue <qiang.xue@gmail.com> 32 * @version $Id: TDropDownList.php 1397 2006-09-07 07:55:53Z wei $ 33 * @package System.Web.UI.WebControls 34 * @since 3.0 35 */ 36 class TDropDownList extends TListControl implements IPostBackDataHandler, IValidatable 37 { 38 /** 39 * Adds attributes to renderer. 40 * @param THtmlWriter the renderer 41 */ 42 protected function addAttributesToRender($writer) 43 { 44 $writer->addAttribute('name',$this->getUniqueID()); 45 parent::addAttributesToRender($writer); 46 } 47 48 /** 49 * Gets the name of the javascript class responsible for performing postback for this control. 50 * This method overrides the parent implementation. 51 * @return string the javascript class name 52 */ 53 protected function getClientClassName() 54 { 55 return 'Prado.WebUI.TDropDownList'; 56 } 57 58 /** 59 * Loads user input data. 60 * This method is primarly used by framework developers. 61 * @param string the key that can be used to retrieve data from the input data collection 62 * @param array the input data collection 63 * @return boolean whether the data of the component has been changed 64 */ 65 public function loadPostData($key,$values) 66 { 67 if(!$this->getEnabled(true)) 68 return false; 69 $this->ensureDataBound(); 70 $selection=isset($values[$key])?$values[$key]:null; 71 if($selection!==null) 72 { 73 $index=$this->getItems()->findIndexByValue($selection,false); 74 if($this->getSelectedIndex()!==$index) 75 { 76 $this->setSelectedIndex($index); 77 return true; 78 } 79 } 80 return false; 81 } 82 83 /** 84 * Raises postdata changed event. 85 * This method is required by {@link IPostBackDataHandler} interface. 86 * It is invoked by the framework when {@link getSelectedIndex SelectedIndex} property 87 * is changed on postback. 88 * This method is primarly used by framework developers. 89 */ 90 public function raisePostDataChangedEvent() 91 { 92 if($this->getAutoPostBack() && $this->getCausesValidation()) 93 $this->getPage()->validate($this->getValidationGroup()); 94 $this->onSelectedIndexChanged(null); 95 } 96 97 /** 98 * @return integer the index (zero-based) of the item being selected. 99 * If none is selected, the return value is 0 meaning the first item is selected. 100 * If there is no items, it returns -1. 101 */ 102 public function getSelectedIndex() 103 { 104 $index=parent::getSelectedIndex(); 105 if($index<0 && $this->getHasItems()) 106 { 107 $this->setSelectedIndex(0); 108 return 0; 109 } 110 else 111 return $index; 112 } 113 114 /** 115 * @throws TNotSupportedException if this method is invoked 116 */ 117 public function setSelectedIndices($indices) 118 { 119 throw new TNotSupportedException('dropdownlist_selectedindices_unsupported'); 120 } 121 122 /** 123 * Returns the value to be validated. 124 * This methid is required by IValidatable interface. 125 * @return mixed the value of the property to be validated. 126 */ 127 public function getValidationPropertyValue() 128 { 129 return $this->getSelectedValue(); 130 } 131 } 132 ?>
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 |