在flex的AdvancedDataGrid中使用xml作为数据时遇到的问题
varxml:XML=<module><modulesmod="module1"><coursecourseid="m1u0"coursename="教学目标"lasts...
var xml:XML = <module>
<modules mod = "module1">
<course courseid = "m1u0" coursename = "教学目标" lastsavetime = "2013-8-1"/>
<course courseid = "m1u1" coursename = "Unit1" lastsavetime = "2013-8-2"/>
<course courseid = "m1u2" coursename = "Unit2" lastsavetime = "2013-8-3"/>
</modules>
<modules mod = "module2">
<course courseid = "m2u0" coursename = "教学目标" lastsavetime = "2013-8-4"/>
<course courseid = "m2u1" coursename = "Unit1" lastsavetime = "2013-8-5"/>
<course courseid = "m2u2" coursename = "Unit2" lastsavetime = "2013-8-6"/>
</modules>
<modules mod = "module3">
<course courseid = "m3u0" coursename = "教学目标" lastsavetime = "2013-8-7"/>
<course courseid = "m3u1" coursename = "Unit1" lastsavetime = "2013-8-8"/>
<course courseid = "m3u2" coursename = "Unit2" lastsavetime = "2013-8-9"/>
</modules>
<modules mod = "module4">
<course courseid = "m4u0" coursename = "教学目标" lastsavetime = "2013-8-10"/>
<course courseid = "m4u1" coursename = "Unit1" lastsavetime = "2013-8-11"/>
<course courseid = "m4u2" coursename = "Unit2" lastsavetime = "2013-8-12"/>
</modules>
<modules mod = "module5">
<course courseid = "m5u0" coursename = "教学目标" lastsavetime = "2013-8-13"/>
<course courseid = "m5u1" coursename = "Unit1" lastsavetime = "2013-8-14"/>
<course courseid = "m5u2" coursename = "Unit2" lastsavetime = "2013-8-15"/>
</modules>
</module>;
这样的一个xml如何绑定到AdvancedDataGrid中? 展开
<modules mod = "module1">
<course courseid = "m1u0" coursename = "教学目标" lastsavetime = "2013-8-1"/>
<course courseid = "m1u1" coursename = "Unit1" lastsavetime = "2013-8-2"/>
<course courseid = "m1u2" coursename = "Unit2" lastsavetime = "2013-8-3"/>
</modules>
<modules mod = "module2">
<course courseid = "m2u0" coursename = "教学目标" lastsavetime = "2013-8-4"/>
<course courseid = "m2u1" coursename = "Unit1" lastsavetime = "2013-8-5"/>
<course courseid = "m2u2" coursename = "Unit2" lastsavetime = "2013-8-6"/>
</modules>
<modules mod = "module3">
<course courseid = "m3u0" coursename = "教学目标" lastsavetime = "2013-8-7"/>
<course courseid = "m3u1" coursename = "Unit1" lastsavetime = "2013-8-8"/>
<course courseid = "m3u2" coursename = "Unit2" lastsavetime = "2013-8-9"/>
</modules>
<modules mod = "module4">
<course courseid = "m4u0" coursename = "教学目标" lastsavetime = "2013-8-10"/>
<course courseid = "m4u1" coursename = "Unit1" lastsavetime = "2013-8-11"/>
<course courseid = "m4u2" coursename = "Unit2" lastsavetime = "2013-8-12"/>
</modules>
<modules mod = "module5">
<course courseid = "m5u0" coursename = "教学目标" lastsavetime = "2013-8-13"/>
<course courseid = "m5u1" coursename = "Unit1" lastsavetime = "2013-8-14"/>
<course courseid = "m5u2" coursename = "Unit2" lastsavetime = "2013-8-15"/>
</modules>
</module>;
这样的一个xml如何绑定到AdvancedDataGrid中? 展开
2个回答
展开全部
XML不行,那会只认识一个对象。你至少需要转换成XMLList,然后会默认转换成 XMLListCollection,直接使用。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-09-03
展开全部
[Bindable]var xc:XMLListCollection = new XMLListCollection(xml.modules);
<adg dataProvider={xc}/>
追问
我在列中的dataField分别这样写"@mod","@courseid","@coursename","@lastsavetime"但是只能显示第一列,大侠这个怎么搞
追答
哦,如果你要最终显示的数据是每个course,那应该这么写
[Bindable]var xc:XMLListCollection = new XMLListCollection(xml..course);
<adg dataProvider={xc}/>
这样后面三个可以显示出来了,但是mod那一列不行,可以通过写labelfunction解决,取父节点的@mod值
<mx:AdvancedDataGridColumn labelFunction="modLabelFunction"/>
private function modLabelFunction(item:Object, column:AdvancedDataGridColumn):String
{
var xx:XML = item as XML;
return xx.parent().@mod;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询