访问itemRenderer中的XML节点

时间:2010-03-10 06:50:00

标签: xml flex

[Bindable]public var headingData1:Object = new Object();

<mx:HTTPService id="srv" url="components.xml" resultFormat="object" result="getHeadings(event);"/>

private function getHeadings(evt:ResultEvent):void{
             //Alert.show(xmlData.toString());
             xmlData = evt.result;
             headingData1 = xmlData.root.CIT;
    }


 <CIT id="1" name="CIT" projectname="CSI" projectmonth="March" manager="KingKong" description="Hello Kong">
    <component number="1" title="Title One">
                <link linkname="Excellent" value="5"/>
                <link linkname="Very Good" value = "4"/>
                <link linkname="Good" value = "3"/>
                <link linkname="Fair" value = "2"/>
                <link linkname="Poor" value = "1"/>
    </component>
</CIT>

组合框作为Flex Advanced Datagrid中的itemRenderer

<?xml version="1.0" encoding="utf-8"?>
<mx:ComboBox dataProvider="{data.link}" 
    xmlns:mx="http://www.adobe.com/2006/mxml" labelField="@linkname" change="stuffChanged()">

<mx:Script>
        <![CDATA[
        //skillsDropdownItems
            import mx.controls.dataGridClasses.DataGridListData;
            import flash.events.Event;
            import mx.controls.Alert;
            import mx.core.Application;
            import mx.collections.ArrayCollection;

            override public function set data( value:Object ) : void {
                super.data = value;
                //this.selectedIndex=data;
                //this.selectedIndex=data.link;
            }

            public function handleDataChanged(event:Event):void {       
                // Cast listData to DataGridListData. 
                //var myListData:DataGridListData = DataGridListData(listData);
                //var r:int=myListData.rowIndex;
                //var c:int=myListData.columnIndex;

                // Access information about the data passed 
                // to the cell renderer.
                //this.parentApplication.whateverStuff[c][r]=this.value;
            }   
            public function stuffChanged():void{
            //var myListData:DataGridListData = DataGridListData(listData);
            //var r:int=myListData.rowIndex;
            //var c:int=myListData.columnIndex;
            //Application.application.whateverStuff[r+1][c]=this.value;
           // Alert.show(this.selectedItem.data);
            for(var k in this.selectedItem) 
            Alert.show(k + " : " + this.selectedItem[k]);
            }   
        ]]>
    </mx:Script>
<!--</mx:NumericStepper>-->
</mx:ComboBox>

我需要在组合框中获取linkname值。

我的高级数据网格

<mx:AdvancedDataGrid dataProvider="{headingData1.component}" horizontalScrollPolicy="on" verticalScrollPolicy="on" x="10" y="132" width="100%" height="303" id="adg1" designViewDataType="tree">
        <mx:columns>
            <mx:AdvancedDataGridColumn headerText="Sr No" dataField="number"/>
            <mx:AdvancedDataGridColumn headerText="Parameter" dataField="title"/>
            <mx:AdvancedDataGridColumn headerText="Feedback" width="170" itemRenderer="com.myClasses.myGridDropdownRenderer"/>
            <mx:AdvancedDataGridColumn headerText="Remarks/Comments/Improvement areas" itemRenderer="mx.controls.TextInput" dataField="col3"/>
        </mx:columns>
    </mx:AdvancedDataGrid> 

2 个答案:

答案 0 :(得分:1)

<mx:ComboBox dataProvider="{data.link}" 
    xmlns:mx="http://www.adobe.com/2006/mxml" labelField="@linkname">

答案 1 :(得分:1)

观察:为什么要将headingData1实例化为对象?你正在为它提供一个XML,因此它应该被输入为XML。

这可能是您唯一的实际问题: headingData1 = xmlData.root.CIT可能需要headingData1 = xmlData.root.CIT[0](我必须经常在使用XML时这样做,它与E4X如何工作有关,并且即使在该级别只有一个节点时似乎也使用XMLList。我听过其他的解释,但这个对我有用。)