Prado\Web\UI\WebControls\TRepeaterItem::setItemIndex PHP Метод

setItemIndex() публичный Метод

If the item is not in the item collection (e.g. it is a header item), -1 should be used.
public setItemIndex ( $value )
    public function setItemIndex($value)
    {
        $this->_itemIndex = TPropertyValue::ensureInteger($value);
    }

Usage Example

Пример #1
0
 /**
  * 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;
 }