Class \Prado\Web\UI\WebControls\TAccordion
TAccordion displays an accordion control. Users can click on the view headers to switch among different accordion views. Each accordion view is an independent panel that can contain arbitrary content.
A TAccordion control consists of one or several TAccordionView controls representing the possible accordion views. At any time, only one accordion view is visible (active), which is specified by any of the following properties:
- \Prado\Web\UI\WebControls\setActiveViewIndex - the zero-based integer index of the view in the view collection.
- \Prado\Web\UI\WebControls\setActiveViewID - the text ID of the visible view.
- \Prado\Web\UI\WebControls\setActiveView - the visible view instance. If both \Prado\Web\UI\WebControls\setActiveViewIndex and \Prado\Web\UI\WebControls\setActiveViewID are set, the latter takes precedence.
TAccordion uses CSS to specify the appearance of the accordion headers and panel. By default, an embedded CSS file will be published which contains the default CSS for TTabPanel. You may also use your own CSS file by specifying the \Prado\Web\UI\WebControls\setCssUrl property. The following properties specify the CSS classes used for elements in a TAccordion:
- \Prado\Web\UI\WebControls\setCssClass - the CSS class name for the outer-most div element (defaults to 'accordion');
- \Prado\Web\UI\WebControls\setHeaderCssClass - the CSS class name for nonactive accordion div elements (defaults to 'accordion-header');
- \Prado\Web\UI\WebControls\setActiveHeaderCssClass - the CSS class name for the active accordion div element (defaults to 'accordion-header-active');
- \Prado\Web\UI\WebControls\setViewCssClass - the CSS class for the div element enclosing view content (defaults to 'accordion-view');
When the user clicks on a view header, the switch between the old visible view and the clicked one is animated. You can use the \Prado\Web\UI\WebControls\setAnimationDuration property to set the animation length in seconds; it defaults to 1 second, and when set to 0 it will produce an immediate switch with no animation.
The TAccordion auto-sizes itself to the largest of all views, so it can encompass all of them without scrolling. If you want to specify a fixed height (in pixels), use the \Prado\Web\UI\WebControls\setViewHeight property. When a TAccordion is nested inside another, it's adviced to manually specify a \Prado\Web\UI\WebControls\setViewHeight for the internal TAccordion
To use TAccordion, write a template like following:
<com:TAccordion>
<com:TAccordionView Caption="View 1">
content for view 1
</com:TAccordionView>
<com:TAccordionView Caption="View 2">
content for view 2
</com:TAccordionView>
<com:TAccordionView Caption="View 3">
content for view 3
</com:TAccordionView>
</com:TAccordion>
Class hierarchy
- \Prado\Web\UI\WebControls\TAccordion implements IPostBackDataHandler
- \Prado\Web\UI\WebControls\TWebControl implements IStyleable
- \Prado\Web\UI\TControl implements IRenderable, IBindable
- \Prado\TApplicationComponent
- \Prado\TComponent
Since: 3.2
public
|
addParsedObject(mixed $object) : mixed
Adds object parsed from template to the control.
This method adds only TAccordionView objects into the \Prado\Web\UI\WebControls\getViews collection. All other objects are ignored. |
public
|
|
public
|
|
public
|
getActiveView() : TAccordionView
Returns the currently active view.
This method will examin the ActiveViewID, ActiveViewIndex and Views collection to determine which view is currently active. It will update ActiveViewID and ActiveViewIndex accordingly. |
public
|
getActiveViewID() : string
Returns the ID of the active accordion view.
Note, this property may not return the correct ID. To ensure the correctness, call getActiveView() first. |
public
|
getActiveViewIndex() : int
Returns the index of the active accordion view.
Note, this property may not return the correct index. To ensure the correctness, call getActiveView() first. |
public
|
|
public
|
|
public
|
|
public
|
getDataChanged() : bool
Returns a value indicating whether postback has caused the control data change.
This method is required by the \Prado\Web\UI\IPostBackDataHandler interface. |
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
loadPostData(string $key, array<string|int, mixed> $values) : bool
Loads user input data.
This method is primarly used by framework developers. |
public
|
onPreRender(mixed $param) : mixed
Registers CSS and JS.
This method is invoked right before the control rendering, if the control is visible. |
public
|
raisePostDataChangedEvent() : mixed
Raises postdata changed event.
This method is required by IPostBackDataHandler interface. It is invoked by the framework when \Prado\Web\UI\WebControls\getActiveViewIndex property is changed on postback. This method is primarly used by framework developers. |
public
|
render(mixed $writer) : mixed
Renders the control.
This method overrides the parent implementation by replacing it with the following sequence:
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
protected
|
activateView(TAccordionView $view) : mixed
Activates the specified view.
If there is any other view currently active, it will be deactivated. |
protected
|
|
protected
|
createControlCollection() : TAccordionViewCollection
Creates a control collection object that is to be used to hold child controls
|
protected
|
getClientClassName() : string
Gets the name of the javascript class responsible for performing postback for this control.
This method overrides the parent implementation. |
protected
|
|
protected
|
|
protected
|
|
protected
|
registerStyleSheet() : mixed
Registers the CSS relevant to the TAccordion.
It will register the CSS file specified by \Prado\Web\UI\WebControls\getCssUrl. If that is not set, it will use the default CSS. |