1
votes

I am listing an Arraycollection in a datagrid using flex and inside the datagrid I have a button to delete a row, after that I re-assign the same Arraycollection again by fetching an array from a java service

My Code:

<mx:DataGrid width="100%" height="100%" dataProvider="{xxx}" >
<mx:columns>
    <mx:DataGridColumn dataField="name" headerText="Name"/>
    <mx:DataGridColumn dataField="status" headerText="Status"/>
    <mx:DataGridColumn dataField="path" headerTeUxt="Actions" wordWrap="true" minWidth="120">
        <mx:itemRenderer>
            <mx:Component>
            <mx:Script>
                <![CDATA[
                    protected function deliteminlist(event:MouseEvent):void
                    {
                            //delete a value in arrayCollection
                            //Fetch the array collection from java Service
                            //assigning to variable dataprovider variable
                            _view.xxx = null;
                            _view.xxx = temp;
                            //xxx is the arraycollection and dataprovider for the datagrid
                    }
                ]]>
            </mx:Script>
            <mx:Image source="@Embed(source='/assets/images/clone.png')" click="deliteminlist(event)" />
            </mx:Component>
        </mx:itemRenderer>
    </mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>

This is throwing an error (An internal error has occurred - Error #1010. ) and data is not refreshing in the datagrid.

1
What error were you seeing? From your service? Or from Flex? Or from something else?JeffryHouser
Looks like there is a race condition , it is better to dispatch event/other external service handle the service calls rather than the item renderer. I would nt do any business logic in the deliteminlist method, not even remove item from arraycollection.Zeus
@Reboog711 actually this is for vSphere web client plugin , am getting error in FLEX layer only... i tried calling java function separately its working fineasvignesh
@Vignesh Well, what is the error? Please share the full stack trace. Which line of your code is causing the error? As a point of reference; you should never try to delete a row from a DataGrid. Always modify the dataProvider and the DataGrid will automagically detect those changes. If you truly need to remove a row; do so by changing the height of the DataGrid; which will cause the DataGrid to display fewer rows. To delete an item from a dataProvider based on a renderer button click I always dispatch a bubbling event and handle it in the component that contains the DataGrid; not a rendererJeffryHouser
am not deleting a row from datagrid i deleted a item from #datagrid.dataprovider only... it is throwing error at this place _view.xxx = temp; and if i try changing #datagrid.dataprovider = temp that time its working but cant able to overwrite the variableasvignesh

1 Answers

1
votes

You are using inline item renderer. Its scope is different from the parent view so that you can't reference _view.xxx ( not in scope ).

You can try outerDocument keyword to solve this problem.

outerDocument.xxx = null;
outerDocument.xxx = temp;