title: ag-grid angualr i want duplicate the selected row data inside same grid i.e i want copy and pate selected row on button click in the same grid
body: <p>In Ag-grid angular,i have button clone row, i will select a row inside grid and click on clone row it should create same row once again in specified index,i was able to achieve this using following code </p>
  
  <h1> in app.ts::</h1>
  
  <p>clone Row(){</p>
  
  <p>var selectedRowsIndex = this.gridOptions.api.getSelectedNodes();</p>
  
  <pre><code>     var index = selectedRowsIndex[0].rowIndex
  var selectedRows = this.gridOptions.api.getSelectedRows();
  const temp =  [...selectedRows] 
  for (var i = 0; i &lt; selectedRows.length; i++) {
    temp[i].B_CLONE = true;
    temp[i].SNO = 3;
  
  }
  this.gridOptions.api.insertItemsAtIndex(++index,temp)
  </code></pre>
  
  <p>}</p>
  
  <pre><code>&lt;button class="btn btn-info ml-3" (click)="cloneRow()"&gt;Clone Row&lt;/button&gt;
  </code></pre>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;button class="btn btn-info ml-3" (click)="cloneRow()"&gt;Clone Row&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Issue i am facing was, after cloning a row(insertItemsAtIndex)</p>
  
  <ol>
  <li><p>existing row also being changed with new clone row if add any value i.e s.no in gird</p></li>
  <li><p>if i edit any of 2 rows duplicated and change any value in any one cell of row getting changed n both the rows are changed.</p></li>
  </ol>
  
  <p>i want to two rows independent of their values </p>
  
  <p>i am attaching screen short for easy understanding.</p>
  
  <p><a href="https://i.stack.imgur.com/LET92.png" rel="nofollow noreferrer">original grid before clone</a> </p>
  
  <p><a href="https://i.stack.imgur.com/rBR7C.png" rel="nofollow noreferrer">grid after clone</a></p>
  
  <p><a href="https://i.stack.imgur.com/cYnUV.png" rel="nofollow noreferrer">grid after clone changing cell value in one row</a></p>