I was playing around with the Flex LinkBar control this morning and somehow I never noticed it had a direction property. Well, it does, so I made a quick little app which filters an XML data provider based on which tab you’re on.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/08/19/creating-a-vertical-linkbar-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Script>
        <![CDATA[
            [Bindable]
            [Embed(source="assets/bulletCheck.png")]
            public var BulletCheck:Class;

            [Bindable]
            [Embed(source="assets/bulletWarning.png")]
            public var BulletWarning:Class;

            [Bindable]
            [Embed(source="assets/bulletCritical.png")]
            public var BulletCritical:Class;
        ]]>
    </mx:Script>

    <mx:XML id="itemsXML">
        <items>
            <item label="Item 1" status="warning" />
            <item label="Item 2" status="critical" />
            <item label="Item 3" status="critical" />
            <item label="Item 4" status="check" />
            <item label="Item 5" status="warning" />
            <item label="Item 6" status="check" />
            <item label="Item 7" status="check" />
            <item label="Item 8" status="critical" />
        </items>
    </mx:XML>

    <mx:String id="CHECK">check</mx:String>
    <mx:String id="WARNING">warning</mx:String>
    <mx:String id="CRITICAL">critical</mx:String>

    <mx:XMLListCollection id="checkColl"
            source="{itemsXML.item.(@status == CHECK)}" />

    <mx:XMLListCollection id="warningColl"
            source="{itemsXML.item.(@status == WARNING)}" />

    <mx:XMLListCollection id="criticalColl"
            source="{itemsXML.item.(@status == CRITICAL)}" />

    <mx:HBox>
        <mx:LinkBar id="linkBar"
                direction="vertical"
                dataProvider="{viewStack}"
                themeColor="haloOrange" />

        <mx:ViewStack id="viewStack"
                width="200"
                height="120"
                backgroundColor="white">
            <mx:Canvas id="checkCanvas"
                    label="Success ({checkColl.length})"
                    icon="{BulletCheck}"
                    width="100%"
                    height="100%">
                <mx:DataGrid id="checkGrid"
                        dataProvider="{checkColl}"
                        width="100%"
                        height="100%" />
            </mx:Canvas>
            <mx:Canvas id="warningCanvas"
                    label="Warning ({warningColl.length})"
                    icon="{BulletWarning}"
                    width="100%"
                    height="100%">
                <mx:DataGrid id="warningGrid"
                        dataProvider="{warningColl}"
                        width="100%"
                        height="100%" />
            </mx:Canvas>
            <mx:Canvas id="criticalCanvas"
                    label="Critical ({criticalColl.length})"
                    icon="{BulletCritical}"
                    width="100%"
                    height="100%">
                <mx:DataGrid id="criticalGrid"
                        dataProvider="{criticalColl}"
                        width="100%"
                        height="100%" />
            </mx:Canvas>
        </mx:ViewStack>
    </mx:HBox>

</mx:Application>

View source is enabled in the following example.

 
Tagged with:
 
About The Author

Peter deHaan

Peter deHaan currently works for Adobe on the Flex SDK QA team. While not working on Flex, Flash, and ColdFusion applications, Peter enjoys making up bios and writing in 3rd person. Peter's rarely updated blog can be found at blogs.adobe.com/pdehaan/, actionscriptexamples.com, airexamples.com, and coldfusionexamples.com.

0 Responses to Creating a vertical LinkBar in Flex

  1. Bruce says:

    Very good example. I like how you created the XMLListCollection using MXML instead of ActionScript. Very easy to understand what is happening.

  2. Pierre says:

    Nice realisation. I’m looking for to have the same effect than :
    http://weblogs.macromedia.com/khoyt/files/f1040.swf

    Can you give informations how it’s possible to have resizing panel like this, and the open and close panels.

    Thank

  3. judah says:

    Thank you! I didnt know about the direction property.

  4. Jörg says:

    Thank you very much!!!

    I searched for hours how to manage a vertical LinkBar…

  5. Adrian says:

    Now how about having 2 or 3 link bars with items each with view stacks an passing from one to another link bar selecting and deselected the activ tab???

    Thant is something that is bugging me….

  6. Manoj Sinha says:

    Hi,
    I am facing a problem of data binding. I am using web service to fill a grid, in the web method I have to pass two parameters, it will return result of xml document. The same I want to fill in a DataGrid using Adobe Flex Buiider 3.

    Please help me..its urgent

    Sample.mxml

    {_txtuserid.text}

    {_txtpassword.text}

    {token.text}

    After login..i want to fill the result in the datagrid. I am using Sql as backend and Asp dot net pattern for coding in Adobe.

    Help me in doing the same
    thanks in advance

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree