flex如何绑定XML对象?
更改XML里面的属性值时,与XML绑定的视图(表单或者gird)能自动更新显示的数据???注意:不是绑定一般的AS对象。比如:现在有一个xml对象varxml:XML;我...
更改XML里面的属性值时,与XML绑定的视图(表单或者gird)能自动更新显示的数据???注意:不是绑定一般的AS对象。比如:现在有一个xml对象 var xml:XML;我令 xml.@id="other"如何让绑定的视图检测到这种改变
展开
2013-08-31
展开全部
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx=" http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"> <fx:Script>
<![CDATA[
[Bindable]
private var xml:XML = <root>
<item>
<a>a</a>
<b>b</b>
<c>c</c>
</item>
</root>
protected function button1_clickHandler(event:MouseEvent):void
{
var obj:Object = new Object();
obj = xml.child("item")[0];
obj.a = "obj_a";
}
]]>
</fx:Script> <fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:AdvancedDataGrid x="10" y="10" id="adg1" designViewDataType="tree" dataProvider="{xml.child('item')}">
<mx:columns>
<mx:AdvancedDataGridColumn headerText="Column 1" dataField="a"/>
<mx:AdvancedDataGridColumn headerText="Column 2" dataField="b"/>
<mx:AdvancedDataGridColumn headerText="Column 3" dataField="c"/>
</mx:columns>
</mx:AdvancedDataGrid>
<s:Button x="10" y="207" label="Button" click="button1_clickHandler(event)"/>
</s:Application>
这是不是你要的?
<s:Application xmlns:fx=" http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"> <fx:Script>
<![CDATA[
[Bindable]
private var xml:XML = <root>
<item>
<a>a</a>
<b>b</b>
<c>c</c>
</item>
</root>
protected function button1_clickHandler(event:MouseEvent):void
{
var obj:Object = new Object();
obj = xml.child("item")[0];
obj.a = "obj_a";
}
]]>
</fx:Script> <fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:AdvancedDataGrid x="10" y="10" id="adg1" designViewDataType="tree" dataProvider="{xml.child('item')}">
<mx:columns>
<mx:AdvancedDataGridColumn headerText="Column 1" dataField="a"/>
<mx:AdvancedDataGridColumn headerText="Column 2" dataField="b"/>
<mx:AdvancedDataGridColumn headerText="Column 3" dataField="c"/>
</mx:columns>
</mx:AdvancedDataGrid>
<s:Button x="10" y="207" label="Button" click="button1_clickHandler(event)"/>
</s:Application>
这是不是你要的?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询