开发者

Issue with itemEditor in AdvancedDataGrid when using hiearchical data as dataProvider

开发者 https://www.devze.com 2023-02-19 09:00 出处:网络
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 ed

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

精彩评论

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

关注公众号