Hi,

What about creating a custom component extending from Link component. I have
made a simple example, might help you..


##LinkEx.mxml##

<mx:Link xmlns:mx="http://www.macromedia.com/2003/mxml"; click="openLink();">
    <mx:Script>
        import mx.controls.Link;
           
        var link:String;
        
        function openLink()
        {
            getURL(link);
        }
    </mx:Script>
    
</mx:Link>


##yourApp.mxml##

<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";
xmlns:local="*">

<!-- Your entire app code goes here //-->

<mx:Grid width="100%">
   <mx:Repeater id="rptRowRep" dataProvider="{rptModel.report.detail}">
      <mx:GridRow>
         <mx:GridItem horizontalAlign="right">
            <local:Label text="{rptRowRep.currentItem.title}"/>
            <local:LinkEx label="{formatData(rptRowRep.currentItem.alloc)}"
link="{rptRowRep.currentItem.alloc.drilldown}" />
            <local:LinkEx label="{formatData(rptRowRep.currentItem.exp)}"
link="{rptRowRep.currentItem.exp.drilldown}"/>
            <local:LinkEx label="{formatData(rptRowRep.currentItem.enc)}"
link="{rptRowRep.currentItem.enc.drilldown}"/>
         </mx:GridItem>
      </mx:GridRow>
   </mx:Repeater>
</mx:Grid>

</mx:Application>


That's the power of MXML and MXML components...

Hope that helps,

-abdul


-----Original Message-----
From: Cindy Lee [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 01, 2005 9:46 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Dynamic link population



I'm trying to generate a table, each cell of which is a link.
The number of rows in the table can be variable, and the link
for each cell is generated dynamically and passed to Flex as
part of the data model.  Here's an example of what a simplifed
version of the table might look like:

<mx:Grid width="100%">
   <mx:Repeater id="rptRowRep" dataProvider="{rptModel.report.detail}">
      <mx:GridRow>
         <mx:GridItem horizontalAlign="right">
            <mx:Label text="{rptRowRep.currentItem.title}"/>
            <mx:Link label="{formatData(rptRowRep.currentItem.alloc)}"/>
            <mx:Link label="{formatData(rptRowRep.currentItem.exp)}"/>
            <mx:Link label="{formatData(rptRowRep.currentItem.enc)}"/>
         </mx:GridItem>
      </mx:GridRow>
   </mx:Repeater>
</mx:Grid>

I haven't been able to figure out how to correctly pass the url to the
getURL command.  If the urls that I want to link to can be referenced as
rptRowRep.currentItem.alloc.drilldown, rptRowRep.currentItem.exp.drilldown,
rptRowRep.currentItem.enc.drilldown, etc., how do I define the click event
to call up the correct url?

If it matters, the link may or may not be to a Flex page.

Thanks.



 
Yahoo! Groups Links



 






 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Attachment: LinkEx.mxml
Description: Binary data

Reply via email to