tags:

views:

69

answers:

2
[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" 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> 
+1  A: 
<mx:ComboBox dataProvider="{data.link}" 
    xmlns:mx="http://www.adobe.com/2006/mxml" labelField="@linkname">
Amarghosh
Its not working, and the combo box is inside the Advanced Datagrid
what does the combobox display?
Amarghosh
Nothing, it does not even load in the Advanced Datagrid. I have also updated my Advanced DataGrid code
Does it display correct values in forth row (Remarks/Comments/Improvement areas)? if yes, see my updated code - changed the dataProvider.
Amarghosh
That is just a TextInput where input is taken, now i am getting the values inside combo box as Object Object.Not the intended values though.
The <CIT> tag shown in the question - is that the whole `evt.result` or just `xmlData.root.CIT` ?
Amarghosh
Also, is the number of [object object] items in the combobox same as the number of link tags under the component?
Amarghosh
Its just xmlData.root.CITThe whole evt.result has a lot of xml information and tags, i mean various other tags
yes the number of [object object] and the items are same, its 5.
Add a change handler to the combo box and trace out the selected item using `trace(this.selectedItem);for(var k in this.selectedItem) trace(k + " : " + this.selectedItem[k])` Btw, does the first two columns display their data correctly?
Amarghosh
for(var k in this.selectedItem) Alert.show(k + " : " + this.selectedItem[k]);Yea i am getting the value in AlertBox, the linkname and value attributes of XML.
Yes the data is displayed correctly in the first two columns
Are you sure you added `labelField="@linkname"`
Amarghosh
I have updated my itemrenderer code
+1  A: 

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.)

invertedSpear
This also did not work......