fumeng
fumeng

Reputation: 1830

Which Accordion child was selected?

Is there a way to discover, through the Accordion headerRenderer, which child is selected?

I'm using a CanvasButtonAccordionHeader from flexlib and I want to display a component in header of the selectedChild only.

Thanks for any helpful tips.

Upvotes: 0

Views: 214

Answers (1)

Panciz
Panciz

Reputation: 2234

You can use define an inline headerRenderer and use the outerDocument property. This is an example:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:ns="http://code.google.com/p/flexlib/">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <mx:Accordion id="acc" width="400" height="400" headerHeight="40">
        <mx:headerRenderer>
            <fx:Component>
                <ns:CanvasButtonAccordionHeader label="{'selected ' +outerDocument.acc.selectedChild.label}">   
                </ns:CanvasButtonAccordionHeader>
            </fx:Component>
        </mx:headerRenderer>
        <mx:Canvas   label="Personal"  toolTip="Child number one">
            <mx:Label text="Contents of Child 1" />
        </mx:Canvas>
        <mx:Canvas label="Accounts" toolTip="Child number two">
            <mx:Label text="Contents of Child 2" />
        </mx:Canvas>
        <mx:Canvas label="Help" toolTip="Child number three">
            <mx:Label text="Contents of Child 3" />
        </mx:Canvas>
    </mx:Accordion>
</s:Application>

Davide

Upvotes: 1

Related Questions