简体   繁体   中英

Flex 4 Problem using datagroup with XML and item renderer

I have a Datagroup with a custom item renderer the momment I bind it to XML from an http service it stops working.

My XML:

<SDLIST>
<chartlist>
    <reportname>FACTORY STATUS</reportname>
    <reportimage>file:/D:/Work/RapidReport/Images/Charts/Vertical-Linear-Gauges.png</reportimage>
</chartlist>
<chartlist>
    <reportname>FACTORY STATUS</reportname>
    <reportimage>file:/D:/Work/RapidReport/Images/Charts/Vertical-Linear-Gauges.png</reportimage>
</chartlist>

Then My DataGroup:

<s:DataGroup x="10" y="42" width="696" height="414" itemRenderer="myComponents.ChartListComp" dataProvider="{new XMLListCollection(XML(getSpeedDialList.lastResult).SDLIST.charlist)}">

My Http Service:

<mx:HTTPService resultFormat="e4x" id="getSpeedDialList" url="{serverURL}/Reporting/GetSpeedDial.xml" useProxy="false" method="POST" fault="Alert.show('There has been an a problem with the connection.\nPlease check your internet connnection and try again.' + getSpeedDialList.url ,'Connection Error')" showBusyCursor="true"  >

My Component uses:

{data.reportname}

I would apreciate anyhelp, having just moved up from flex 3 I m not sure where this is miss behaving.

Thank you in advance for any help.

Looks like <SDLIST> is your root tag, in that case, getSpeedDialList.lastResult already points to that node - you shouldn't explicitly mention that in the e4x query.

<s:DataGroup x="10" y="42" width="696" height="414" 
    itemRenderer="myComponents.ChartListComp" 
    dataProvider="{getSpeedDialList.lastResult.charlist}">

And you're indeed calling getSpeedDialList.send() from creation-complete or some place like that, aren't you?

I got it to work.

The answer was to set resultFormat="e4x" and then to use {new XMLListCollection(XMLList(getSpeedDialList.lastResult).chartlist)}

the problem seems to be with how datagroups Expect Lists.

But thank you Amarghosh for pointing out the E4X first node is ignored behavior and to Alex Harui at Adobe Flex SDK Team for the XML List Collection when using datagroups comment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM