0 Replies Latest reply on Mar 1, 2011 5:44 PM by jlanpheer

    ''Data synchronization conflict' error.

    jlanpheer

      I have a DataGrid on an .mxml page which looks like this...

       

      <fx:DataGrid id="detailDG" doubleClickEnabled="false" horizontalScrollPolicy="auto" width="100%" dataProvider="{collection}" editable="true" height="100%">
          <fx:columns>
               <mx:Array id="Check">

                  <fx:DataGridColumn dataField="CHECK_NUMBER" editable="false" headerText="Check Number"/>

               etc......

               </mx:Array>
          </fx:columns>
      </fx:DataGrid>

       

      Above that, i have a "Clear" button, whose job is to clear the DataGrid and the collection.

      <mx:Button id="ClearForm" enabled="true" click="clear_onClick()" label="Clear"/>

       

      The function looks something like this:

      private function clear_onClick():void {
              if (gridToUse == "detail") {
                  collection.removeAll();
                  detailDG.dataProvider = null;
                  updateForm.dataProvider = null;               
              }
          }

       

      There is a "Save Changes" button whose code is this:

      <mx:Button enabled="{collection.commitRequired}" click="doUpdate()" label="Save Changes"/>

       

      The code of doUpdate is simple:

      private function doUpdate():void {
              collection.sync();
          }

       

      On the screen below, i have a DataForm where i can see record details or enter a new record.  I can create records to my hearts' content and "save" them, as long as i do not use the "ClearForm" button above.  If i say (1) create a record and save it (2) press "Clear" and then (3) create another record and try and press "Save Changes", i get the following error:

       

      Data Synchronization Error

      Server could not find item to 'delete':
      Destination: com.gwla.cs.au17.datasource.DetailRpt.getDetailRpt
      Previous Item: _detailDTO{CHECK_NUMBER:5577..........etc.}

       

      Default action taken: item removed from the collection

       

      The error references an element in the collection that i had already saved and cleared.  My debugging shows that the length of the collection is zero.  Have i missed something very simple with clearing the collection in my "Clear button" code?  Do i need to do something more than a removeAll to clear it?  If anyone has any ideas, i'd love to hear them.  I've googled this error and am not coming up with any matches.

      cheers,

      jim.