AddRecord() between two row

Hi,

I am using inline edit mode in my Grid and I want use the function this.grid.addRecord() for insert a new row (in edit mode) between the row.

How can i do it?

Thanks


1 Reply

JC Joseph Christ Nithin Issack Syncfusion Team January 26, 2022 02:35 PM UTC

Hi Fabio, 

  Greetings from Syncfusion support. 

  Based on your requirement, you want to add a new record in a desired index on a button click and move the record to edit mode. Your requirement can be achieved by adding the row in the click event of the button using the `addRecord` method and in the actionComplete event of the grid you can select the row using `selectRow` method and move the selected row to the edit mode using the `startEdit` method. 

Please refer the below code example. 


public actionComplete(args) { 
    if (args.requestType == 'save' && this.isCustomadd) { 
      this.isCustomadd = false; 
      this.grid.selectRow(1); // select the added row by using the rowIndex 
      this.grid.editModule.startEdit(); // Call the startEdit method to edit the selected row 
    } 
  } 
 
  public btnClick() { 
    this.isCustomadd = true; 
    this.grid.addRecord( 
      { 
        OrderID: 12345, 
        CustomerID: 'VINET', 
        OrderDate: '1996-07-04T10:10:00.000Z', 
        ShippedDate: '1996-07-16T12:20:00.000Z', 
        Freight: 32.38, 
        ShipName: 'Vins et alcools Chevalier', 
        ShipAddress: '59 rue de l"Abbaye', 
        ShipCity: 'Reims', 
        ShipRegion: null, 
        ShipCountry: 'France', 
      }, 
      1 
    ); 




Please get back to us for further details. 

Regards, 
Joseph I. 


Loader.
Up arrow icon