A TDataListItem control represents an item in the {@link TDataList} control, such as heading section, footer section, or a data item. The index and data value of the item can be accessed via {@link getItemIndex ItemIndex}> and {@link getDataItem DataItem} properties, respectively. The type of the item is given by {@link getItemType ItemType} property.
Since: 3.0
Author: Qiang Xue (qiang.xue@gmail.com)
Inheritance: extends TWebControl, implements Prado\Web\UI\INamingContainer, implements Prado\Web\UI\WebControls\IItemDataRenderer
コード例 #1
0
ファイル: TDataList.php プロジェクト: pradosoft/prado
 /**
  * Creates a datalist item instance based on the item type and index.
  * @param integer zero-based item index
  * @param TListItemType item type
  * @return TControl created datalist item
  */
 protected function createItem($itemIndex, $itemType)
 {
     $template = null;
     $classPath = null;
     switch ($itemType) {
         case TListItemType::Item:
             $classPath = $this->getItemRenderer();
             $template = $this->_itemTemplate;
             break;
         case TListItemType::AlternatingItem:
             list($classPath, $template) = $this->getAlternatingItemDisplay();
             break;
         case TListItemType::SelectedItem:
             list($classPath, $template) = $this->getSelectedItemDisplay($itemIndex);
             break;
         case TListItemType::EditItem:
             list($classPath, $template) = $this->getEditItemDisplay($itemIndex);
             break;
         case TListItemType::Header:
             $classPath = $this->getHeaderRenderer();
             $template = $this->_headerTemplate;
             break;
         case TListItemType::Footer:
             $classPath = $this->getFooterRenderer();
             $template = $this->_footerTemplate;
             break;
         case TListItemType::Separator:
             $classPath = $this->getSeparatorRenderer();
             $template = $this->_separatorTemplate;
             break;
         default:
             throw new TInvalidDataValueException('datalist_itemtype_unknown', $itemType);
     }
     if ($classPath !== '') {
         $item = Prado::createComponent($classPath);
         if ($item instanceof IItemDataRenderer) {
             $item->setItemIndex($itemIndex);
             $item->setItemType($itemType);
         }
     } else {
         if ($template !== null) {
             $item = new TDataListItem();
             $item->setItemIndex($itemIndex);
             $item->setItemType($itemType);
             $template->instantiateIn($item);
         } else {
             $item = null;
         }
     }
     return $item;
 }