3 Replies Latest reply on Aug 14, 2009 2:22 PM by msakrejda

    Does xml.copy() create completely detached copy?

    Zolotoj Level 3

      I am using the following code to add a new row to datagrid:

      ....
      // somewhere in the code, one time when data initially is loaded into DG
      newDocument = XML(documents.dataProvider[0]).copy();
      ....
      // later
      var NewDocument:XML = newDocument.copy();
      NewDocument.id = 0;
      NewDocument.docdescript = "";
      NewDocument.link = "";
      NewDocument.attached = "";
      documents.dataProvider.addItem(NewDocument);
      documents.scrollToIndex(documents.dataProvider.length - 1);
      documents.selectedIndex = documents.dataProvider.length - 1;
      documents.validateNow();
      

      What's happening is when I add a second row both first and second become the same.

      What is a problem here?

       

      Thanks