Prado\Web\UI\WebControls\TMultiView::setActiveViewIndex PHP Метод

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

public setActiveViewIndex ( $value )
    public function setActiveViewIndex($value)
    {
        if (($index = TPropertyValue::ensureInteger($value)) < 0) {
            $index = -1;
        }
        $views = $this->getViews();
        $count = $views->getCount();
        if ($count === 0 && $this->getControlStage() < TControl::CS_CHILD_INITIALIZED) {
            $this->_cachedActiveViewIndex = $index;
        } else {
            if ($index < $count) {
                $this->setControlState('ActiveViewIndex', $index, -1);
                $this->_cachedActiveViewIndex = -1;
                if ($index >= 0) {
                    $this->activateView($views->itemAt($index), true);
                }
            } else {
                throw new TInvalidDataValueException('multiview_activeviewindex_invalid', $index);
            }
        }
    }

Usage Example

Пример #1
0
 /**
  * @param integer the zero-based index of the current view in the view collection. -1 if no active view.
  * @throws TInvalidDataValueException if the view index is invalid
  */
 public function setActiveViewIndex($value)
 {
     parent::setActiveViewIndex($value);
     if ($this->getActiveControl()->canUpdateClientSide()) {
         $this->getPage()->getAdapter()->registerControlToRender($this, $this->getResponse()->createHtmlWriter());
     }
 }