简体   繁体   English

Flex 4在XML和项目渲染器中使用数据组的问题

[英]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. 我有一个带有自定义项目渲染器的数据组,但我将其从http服务停止工作的XML绑定到XML。

My XML: 我的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: 我的Http服务:

<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. 我将不胜感激,刚刚从flex 3上移了一下,我不确定这是哪里出现的问题。

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. 看起来<SDLIST>是您的根标记,在这种情况下, getSpeedDialList.lastResult已经指向该节点-您不应在e4x查询中明确提及。

<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? 而且您确实是在创建完成或诸如此类的地方调用getSpeedDialList.send() ,不是吗?

I got it to work. 我知道了。

The answer was to set resultFormat="e4x" and then to use {new XMLListCollection(XMLList(getSpeedDialList.lastResult).chartlist)} 答案是设置resultFormat =“ e4x”,然后使用{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. 但是,感谢Amarghosh指出使用数据组注释时,E4X的第一个节点被忽略的行为以及Adobe Flex SDK团队的XML List Collection的Alex Harui。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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