Following is the sample code.

While I start editing either in optionId column or option column, the other rows of the same column are also get affected and reflecting the same value. But when I am editing in other columns it is working fine... Don't know the reason. If anybody could help me.

 <mx:AdvancedDataGrid id="electionGrid" width="100%" height="70%" folderOpenIcon="{null}" folderClosedIcon="{null}" defaultLeafIcon="{null}" editable="true">
        <mx:dataProvider>
            <mx:HierarchicalData source="{electionSummary}" childrenField="options"/>
        </mx:dataProvider>
        <mx:columns>
            <mx:AdvancedDataGridColumn dataField="dbProduct" headerText="DB Product" editable="false"/>             
            <mx:AdvancedDataGridColumn dataField="entitledQty" headerText="Entitled Quantity" editable="false"/>
            <mx:AdvancedDataGridColumn dataField="entityId" headerText="Entity Id" editable="false"/>
            <mx:AdvancedDataGridColumn dataField="entityName" headerText="Entity Name" editable="false"/>
            <mx:AdvancedDataGridColumn dataField="eventStatus" headerText="Event Status" editable="false"/>
            <mx:AdvancedDataGridColumn dataField="optionId" headerText="Option Id" itemEditor="mx.controls.TextInput" editorDataField="text"/>
            <mx:AdvancedDataGridColumn dataField="option" headerText="Description" itemEditor="mx.controls.TextInput" editorDataField="text"/>            
        </mx:columns>        
    </mx:AdvancedDataGrid>

Hiearchical Data :

 <mx:ArrayCollection id="optionData">
    <model:CAEventOption optionId="12345" option="Option1"/> 
    <model:CAEventOption optionId="56789" option="Option2"/>
    <model:CAEventOption optionId="89756" option="Option3"/>        
</mx:ArrayCollection>

<mx:ArrayCollection id="electionSummary">
    <model:ElectionStatusSummary dbProduct="Global PB" entitledQty="54500" entityId="DEM0001" entityName="Hedge Fund Long Short Period" 
                eventStatus="Awaiting Election" options="{new ArrayCollection(optionData.source)}"/>
    <model:ElectionStatusSummary dbProduct="Global PB" entitledQty="54500" entityId="DEM0001" entityName="Hedge Fund Long Short Period" 
                eventStatus="Awaiting Election" options="{new ArrayCollection(optionData.source)}"/>
    <model:ElectionStatusSummary dbProduct="Global PB" entitledQty="54500" entityId="DEM0001" entityName="Hedge Fund Long Short Period" 
                eventStatus="Awaiting Election" options="{new ArrayCollection(optionData.source)}"/>        
</mx:ArrayCollection>
有帮助吗?

解决方案

{new ArrayCollection(optionData.source)} creates a new ArrayCollection. However, the underlying Array is always the same object (here optionData).

To prevent this from happening you'll have to create three different arrays containing different instances of CAEventOption. Something link this:

<mx:ArrayCollection id="electionSummary">
    <model:ElectionStatusSummary dbProduct="Global PB" entitledQty="54500" entityId="DEM0001"
                                 entityName="Hedge Fund Long Short Period" eventStatus="Awaiting Election">
        <model:options>
            <mx:ArrayCollection id="optionData">
                <model:CAEventOption optionId="12345" option="Option1"/>
                <model:CAEventOption optionId="56789" option="Option2"/>
                <model:CAEventOption optionId="89756" option="Option3"/>
            </mx:ArrayCollection>
        </model:options>
    </model:ElectionStatusSummary>
    <model:ElectionStatusSummary dbProduct="Global PB" entitledQty="54500" entityId="DEM0001"
                                 entityName="Hedge Fund Long Short Period" eventStatus="Awaiting Election">
        <model:options>
            <mx:ArrayCollection id="optionData">
                <model:CAEventOption optionId="12345" option="Option1"/>
                <model:CAEventOption optionId="56789" option="Option2"/>
                <model:CAEventOption optionId="89756" option="Option3"/>
            </mx:ArrayCollection>
        </model:options>
    </model:ElectionStatusSummary>
    <model:ElectionStatusSummary dbProduct="Global PB" entitledQty="54500" entityId="DEM0001"
                                 entityName="Hedge Fund Long Short Period" eventStatus="Awaiting Election">
        <model:options>
            <mx:ArrayCollection id="optionData">
                <model:CAEventOption optionId="12345" option="Option1"/>
                <model:CAEventOption optionId="56789" option="Option2"/>
                <model:CAEventOption optionId="89756" option="Option3"/>
            </mx:ArrayCollection>
        </model:options>
    </model:ElectionStatusSummary>
</mx:ArrayCollection>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top