Flex 3 数据网格和 xmllistcollection

发布于 2024-08-13 01:46:32 字数 309 浏览 5 评论 0原文

我试图在数据网格中的不同字段中显示 xmllistcollection 的内容,但是除非我使用 itemrenderer,否则该值不会显示在网格中。

xmllistcollection 是通过 Web 服务调用填充的。在我的项目渲染器中,我使用自定义命名空间从 xmllistcollection 检索内容,

value.ns::firstName

但是如果我在数据网格中尝试类似 dataField = "ns::firstName" 的内容而不使用项目渲染器,我将得不到数据输出。

有人可以帮我吗?

im trying to display content of xmllistcollection in different fields in my datagrid however unless i use an itemrenderer the value is not displaying in the grid.

the xmllistcollection is populated from a webservice call. Inside my item renderer i use a custom namesspace to retrieve contents from the xmllistcollection

value.ns::firstName

however if i try something like dataField = "ns::firstName" in the datagrid without using an item renderer i get no data output.

Can anyone help me out?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

著墨染雨君画夕 2024-08-20 01:46:32

使用 labelFunction 属性

<mx:DataGrid dataProvider="{xml.ns::user}">
    <mx:columns>
        <mx:DataGridColumn labelFunction="nameLabelFunc" headerText="Name"/>
        <mx:DataGridColumn labelFunction="ageLabelFunc" headerText="Age"/>
    </mx:columns>
</mx:DataGrid>
<mx:XML source="data.xml" id="xml"/>
<mx:Script>
    <![CDATA[
        import mx.controls.dataGridClasses.DataGridColumn;
        private var ns:Namespace = new Namespace("http://www.adobe.com");
        public function nameLabelFunc(item:Object, col:DataGridColumn):String
        {
            return item.ns::name;
        }
        public function ageLabelFunc(item:Object, col:DataGridColumn):String
        {
            return item.ns::age;
        }
    ]]>
</mx:Script>

数据.xml

<userInfo xmlns="http://www.adobe.com">
  <user>
    <name>John</name>
    <age>34</age>
  </user>
  <user>
    <name>Gessy</name>
    <age>32</age>
  </user>
</userInfo>

Use the labelFunction property.

<mx:DataGrid dataProvider="{xml.ns::user}">
    <mx:columns>
        <mx:DataGridColumn labelFunction="nameLabelFunc" headerText="Name"/>
        <mx:DataGridColumn labelFunction="ageLabelFunc" headerText="Age"/>
    </mx:columns>
</mx:DataGrid>
<mx:XML source="data.xml" id="xml"/>
<mx:Script>
    <![CDATA[
        import mx.controls.dataGridClasses.DataGridColumn;
        private var ns:Namespace = new Namespace("http://www.adobe.com");
        public function nameLabelFunc(item:Object, col:DataGridColumn):String
        {
            return item.ns::name;
        }
        public function ageLabelFunc(item:Object, col:DataGridColumn):String
        {
            return item.ns::age;
        }
    ]]>
</mx:Script>

data.xml

<userInfo xmlns="http://www.adobe.com">
  <user>
    <name>John</name>
    <age>34</age>
  </user>
  <user>
    <name>Gessy</name>
    <age>32</age>
  </user>
</userInfo>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文