【问题标题】:Flex 4 Problem using datagroup with XML and item rendererFlex 4 使用带有 XML 和项目渲染器的数据组的问题
【发布时间】:2010-09-08 09:51:34
【问题描述】:

我有一个带有自定义项目渲染器的数据组,当我将它从停止工作的 http 服务绑定到 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>

然后是我的数据组:

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

我的 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"  >

我的组件使用:

{data.reportname}

我会感谢任何帮助,刚从 flex 3 升级,我不确定这是哪里的失误。

提前感谢您的帮助。

【问题讨论】:

    标签: xml apache-flex data-binding flex4 itemrenderer


    【解决方案1】:

    看起来&lt;SDLIST&gt; 是您的根标签,在这种情况下,getSpeedDialList.lastResult 已经指向该节点 - 您不应在 e4x 查询中明确提及。

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

    你确实是从创建完成或类似的地方调用getSpeedDialList.send(),不是吗?

    【讨论】:

    • 您好,首先感谢您抽出宝贵时间尝试帮助我。我已经删除了隐式 resultType,并将 dataprovider 置于您建议的格式中。但是项目渲染器现在什么也没显示。
    • 我也试过"{new XMLListCollection(XMLList(getSpeedDialList.lastResult).SDLIST.charlist)}
    • @Craig 我没有要求您删除 resultFormat="e4x" - 我说的是 you shouldn't explicitly mention that in the e4x query. - 我的意思是说从 e4x 查询 SDLIST.charlist 中删除 SDLIST。从您的另一篇文章看来,这正是您最终实现它的方式。
    【解决方案2】:

    我让它工作了。

    答案是设置 resultFormat="e4x" 然后使用 {new XMLListCollection(XMLList(getSpeedDialList.lastResult).chartlist)}

    问题似乎与数据组期望列表的方式有关。

    但感谢 Amarghosh 指出 E4X 第一个节点被忽略的行为并 Adobe Flex SDK 团队的 Alex Harui 使用数据组评论时的 XML 列表集合。

    【讨论】:

      猜你喜欢
      • 2010-12-20
      • 2011-08-16
      • 2014-01-19
      • 2011-03-09
      • 2010-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多