Prado\Web\UI\WebControls\TRepeaterItem::setItemType PHP Method

setItemType() public method

public setItemType ( $value )
    public function setItemType($value)
    {
        $this->_itemType = TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TListItemType');
    }

Usage Example

コード例 #1
0
ファイル: TRepeater.php プロジェクト: pradosoft/prado
 /**
  * Creates a repeater item instance based on the item type and index.
  * @param integer zero-based item index
  * @param TListItemType item type
  * @return TControl created repeater 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:
             if (($classPath = $this->getAlternatingItemRenderer()) === '' && ($template = $this->_alternatingItemTemplate) === null) {
                 $classPath = $this->getItemRenderer();
                 $template = $this->_itemTemplate;
             }
             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('repeater_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 TRepeaterItem();
             $item->setItemIndex($itemIndex);
             $item->setItemType($itemType);
             $template->instantiateIn($item);
         } else {
             $item = null;
         }
     }
     return $item;
 }