TPanel represents a component that acts as a container for other component.
It is especially useful when you want to generate components programmatically
or hide/show a group of components.
By default, TPanel displays a <div> element on a page.
Children of TPanel are displayed as the body content of the element.
The property {@link setWrap Wrap} can be used to set whether the body content
should wrap or not. {@link setHorizontalAlign HorizontalAlign} governs how
the content is aligned horizontally, and {@link getDirection Direction} indicates
the content direction (left to right or right to left). You can set
{@link setBackImageUrl BackImageUrl} to give a background image to the panel,
and you can ste {@link setGroupingText GroupingText} so that the panel is
displayed as a field set with a legend text. Finally, you can specify
a default button to be fired when users press 'return' key within the panel
by setting the {@link setDefaultButton DefaultButton} property.
/** * Renders and replaces the panel's content on the client-side. * When render() is called before the OnPreRender event, such as when render() * is called during a callback event handler, the rendering * is defered until OnPreRender event is raised. * @param THtmlWriter html writer */ public function render($writer) { if ($this->getHasPreRendered()) { parent::render($writer); if ($this->getActiveControl()->canUpdateClientSide()) { $this->getPage()->getCallbackClient()->replaceContent($this, $writer); } } else { $this->getPage()->getAdapter()->registerControlToRender($this, $writer); if ($this->getHasControls()) { // If we update a TActivePanel on callback, // We shouldn't update all childs, because the whole content will be replaced by // the parent foreach ($this->findControlsByType('IActiveControl', false) as $control) { $control->getActiveControl()->setEnableUpdate(false); } } } }
/** * Ensure that the ID attribute is rendered and registers the javascript code * for initializing the active control. */ protected function addAttributesToRender($writer) { parent::addAttributesToRender($writer); $cs = $this->getPage()->getClientScript(); if ($this->getGhosting() == TDraggableGhostingOptions::SuperGhosting) { $cs->registerPradoScript('dragdropextra'); } else { $cs->registerPradoScript('dragdrop'); } $writer->addAttribute('id', $this->getClientID()); $options = TJavaScript::encode($this->getPostBackOptions()); $class = $this->getClientClassName(); $code = "new {$class}('{$this->getClientId()}', {$options}) "; $cs->registerEndScript(sprintf('%08X', crc32($code)), $code); }
/** * Renders and replaces the panel's content on the client-side. * When render() is called before the OnPreRender event, such as when render() * is called during a callback event handler, the rendering * is defered until OnPreRender event is raised. * @param THtmlWriter html writer */ public function render($writer) { if ($this->getHasPreRendered()) { parent::render($writer); if ($this->getActiveControl()->canUpdateClientSide()) { $this->getPage()->getCallbackClient()->replaceContent($this->_container, $writer); } } else { $this->getPage()->getAdapter()->registerControlToRender($this->_container, $writer); } }