Hi All,

I was looking into DataGrid Example from FB's Help of rendaring a 
header.

I have used TextArea to display ColIndex in each corresponding 
header, which is working fine.

Here, I want to display a combobox with unique value of that 
purticular coloumn. When I changed TextArea to ComboBox and 
compiled, It doesnt show anything on the screen. Can anyone tell me, 
Why?

If I use HBox in place of TextArea and add ComboBox inside HBox, 
Combobox appears on the screen but it doesnt "listData" as it is a 
public property of TextArea. How can I get the dataField Name of 
Randared column?

Or

Is there any other way to rendar a grid header to populate the 
combobox with using column value?

Please help me to resolve this issue.

Thanks,
Sanjay sharma


 =========================  GridHeaderRendar.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
        layout="absolute"  
        xmlns:local="*" xmlns:gridCode="*" >
<mx:Script>
        <![CDATA[
import mx.collections.*;

[Bindable]
       public var authorsDataProvider : ArrayCollection = new 
ArrayCollection( [
            {sNo: "1", Selected: "", Country: "USA", Gold: 35, 
Status:"Active", URL:"http://www.google.com"; },
            {sNo: "2", Selected: "", Country: "China", Gold: 32, 
Status:"Deactive",URL:"http://www.yahoo.com"},
            {sNo: "3", Selected: "", Country: "Russia", Gold: 
27,Status:"Deactive", URL:"http://www.hotmail.com"; },
            {sNo: "4", Selected: "", Country: "India", Gold: 12, 
Status:"Active",URL:"http://www.gmail.com"},
            {sNo: "5",Selected: "", Country: "Russia", Gold: 27, 
Status:"Deleted",URL:"http://www.hotmail.com"; } ]);

        ]]>
</mx:Script>


<mx:Panel title="Header Filter" width="700" height="400">
      <!-- <gridCode:gridCode  
dataProvider="{authorsDataProvider}" />  -->
      <mx:DataGrid id="grid" width="100%" height="300" 
dataProvider="{authorsDataProvider}" >
        <mx:columns>
          <mx:DataGridColumn id="sNo"  headerText="Serial Number"   
dataField="sNo" headerRenderer="testCombo" />
            <mx:DataGridColumn id="Selected"  headerText="Selected 
Item" itemRenderer="MyContactEditable" headerRenderer="testCombo"  
dataField="Selected"  />
            <mx:DataGridColumn id="Country"   headerText="Country 
name" dataField="Country" headerRenderer="testCombo"  />
            <mx:DataGridColumn id="Status" width="300"   
headerText="Status" dataField="Status"  headerRenderer="testCombo" 
sortable="false"/>
            <mx:DataGridColumn id="Gold"  headerText="Gold" 
dataField="Gold" />

       </mx:columns>
      </mx:DataGrid>
</mx:Panel>
</mx:Application>

============ testCombo.mxml (withTextArea) ================= 

<?xml version="1.0"?>
<mx:TextArea xmlns:mx="http://www.adobe.com/2006/mxml";     
preinitialize ="initTA();">

    <mx:Script>
        <![CDATA[
            import mx.controls.dataGridClasses.DataGridListData; 
            public function initTA():void {
                var myListData:DataGridListData = DataGridListData
(listData);
                 text="row Name: " + String(myListData.dataField) 
            }    
        ]]>
    </mx:Script>
</mx:TextArea>

============ testCombo.mxml (with ComboBox) ================= 

<?xml version="1.0"?>
<mx:ComboBox xmlns:mx="http://www.adobe.com/2006/mxml";     
preinitialize ="initTA();">

    <mx:Script>
        <![CDATA[
            import mx.controls.dataGridClasses.DataGridListData; 
            public function initTA():void {
                var myListData:DataGridListData = DataGridListData
(listData);
                 //text="row Name: " + String(myListData.dataField) 
            }    
        ]]>
    </mx:Script>
</mx:ComboBox>

============ testCombo.mxml (with HBox) ================= 

<?xml version="1.0"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml";     preinitialize 
="initTA();">

    <mx:Script>
        <![CDATA[
            import mx.controls.dataGridClasses.DataGridListData; 
            public function initTA():void {
                var myListData:DataGridListData = DataGridListData
(listData);
                 //text="row Name: " + String(myListData.dataField) 
            }    
        ]]>
    </mx:Script>
    <mx:ComboBox id="te" />
</mx:HBox>

Reply via email to