开发者

Accessing the XML nodes in itemRenderer

开发者 https://www.devze.com 2022-12-22 06:08 出处:网络
[Bindable]public var headingData1:Object = new Object(); <mx:HTTPService id=\"srv\" url=\"components.xml\" resultFormat=\"object\" result=\"getHeadings(event);\"/>
[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>

Combo Box as an itemRenderer in Flex Advanced Datagrid

<?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>

I need to get the linkname values in my combobox.

My Advanced Datagrid

<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" data开发者_StackOverflow中文版Field="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> 


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


An observation: Why make instantiating headingData1 as an object? you're feeding it an XML, so it should be typed as an XML.

This may be your only actual problem: headingData1 = xmlData.root.CIT may need to be headingData1 = xmlData.root.CIT[0] (I have to do this often when working with XML, it has to do with how E4X works and seems to use XMLList even when there is only one node at that level. I've heard other explanations, but this one makes sense to me.)

0

精彩评论

暂无评论...
验证码 换一张
取 消