Search code examples
javascriptjqueryslickgrid

SlickGrid_AppendNew Row with different Id


I m using slickgrid V2.2, I am trying to append new row from the selected row along with data in the selected row. Its working fine, but in the added row the same id generating as the selected row by default. I am using below code. Kindly help me out to append a new row with different id from selectedrow

             var row = grid.getDataItem(selectedRow);
                       dataView.addItem(row);
                       grid.render();
                       grid.setSelectedRows([]);

Solution

  • row is simply an object containing the columns, so row.id = {new id}; should work. You'll need to generate the id somehow depending on how your scheme works (don't use the curly brackets around the new id value, I'm just indicating that this value needs to be inserted).