2 Replies Latest reply on Apr 21, 2010 7:09 AM by megharajdeepak

    Problems in cancel functionality for a datagrid

    megharajdeepak Level 1

      Hi there,


      I have a datagrid which has been assigned a bindable array collection variable to it's dataprovider, acData.

      <mx:DataGrid id="dg" x="200" y="81" editable="true" dataProvider="{acData}">


      As soon as the application is loaded, some data is flown into acData, which in turn shows up in the datagrid.

      acData = event.result;



      I tried to create a copy of this data so that I can use it, in case the user cancels the data entry. Hence, as soon as the data is loaded, I assigned the data to acData and also another array collection named acBackUp.


      acData = event.result;

      acBackUp = event.result;


      Since the datagrid is editable, user can make changes in the datagrid. But there is a button called 'Cancel' at the bottom. If user clicks this button after making some changes in the datagrid, I want to assign the back up array collection to acData, ie,.

      On click of cancel - > acData = acBackUp;


      But what I noticed was even before assigning the back up ac to acData, acBackUp has be overwritten with the values that were entered in the datagrid. It wont have those old, event.result values in it.


      Am I doing something wrong here ? How can I store the old values in some array collection and use it back for the datagrid?


      pls help....