We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to get newly inserted row data from endadd event in grid?

I am trying to get newly inserted rowdata(cell values) from endadd event of grid and trying to send it to webapi. I look every where in documentation but not find any way to process the args parameter. Below are code snippets.

var dataManager = ej.DataManager({
url: "http://localhost:1895/api/customer",
crossDomain: true,
adaptor: new ej.WebApiAdaptor(),
offline: true,
});


$("#grid").ejGrid({
dataSource: dataManager,
//allowFiltering: "true",
allowResizing: "true",
endAdd: senddatatoserver, // endadd event handler
    allowGrouping: "true",
isResponsive: "true",
allowResizeToFit: "true",
allowPaging: "true",
allowScrolling: "true",
allowSorting: "true",
allowReordering: "true",
recordClick: function getInfo(args) {
if (args.target.classList.contains("e-rowcell")) {
console.log(this.ej2_instances[0].getRowInfo(args.target)); // for getting row info based on click
}
},
allowMultiSorting: "true",
allowSearching: "true",
enableResponsiveRow: "true",
contextMenuSettings: {enableContextMenu: true},
enableHeaderHover: "true",
enableAltRow: "true",
enableRowHover: "true",
scrollSettings: {width: screen.availWidth},
pageSettings: {pageSize: 10},
editSettings: {allowAdding: "true", allowDeleting: "true", allowEditing: "true"},
toolbarSettings: {
showToolbar: true,
toolbarItems: [ej.Grid.ToolBarItems.Add, ej.Grid.ToolBarItems.Edit, ej.Grid.ToolBarItems.Delete, ej.Grid.ToolBarItems.Search, ej.Grid.ToolBarItems.Update, ej.Grid.ToolBarItems.Cancel]
},

}); 


var func = function senddatatoserver(args) {
$("#dialog").ejDialog(
{
actionButtons: ["close"],
title: "Record added",
}
);
$("#addcontent").text("Row Inserted Succesfully" + a);
//how to process args to get newly inserted row and send to the webapi as post request.

};


3 Replies

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team July 16, 2019 04:50 AM

Hi Muhammad, 

Thanks for contacting Syncfusion Support. 

Query#:- I am trying to get newly inserted rowdata(cell values) from endadd event of grid and trying to send it to webapi. 

We have checked your query and by default while using webAPI adaptor after hitting the post request, endAdd method will get trigger. You can get the inserted data after the returning the post request.  So before proceeding your query we need some more additional details to find the cause of the issue. Share us the following details. 

  1. For which purpose you need to send inserted data to server side.(Do you need to perform any operations on server end).
  2. Exact scenario you need to achieve.

Regards, 

Farveen sulthana T 



MZ Muhammad Zeshan July 16, 2019 05:05 AM

Scenario: When I insert data in grid it just add in grid no post request is made to webapi. I want to achieve, getting data from endadd event(newly inserted row) and send it to webapi to insert in database.

Problem: I don't know how to get values of newly inserted row from args object in endadd event.


What solution I want: Just show me way how to get newly inserted row data of grid in endadd event via event args object.

Thankyou.


FS Farveen Sulthana Thameeztheen Basha Syncfusion Team July 17, 2019 01:19 AM

Hi Muhammad,  
 
 Query#:- What solution I want: Just show me way how to get newly inserted row data of grid in endadd event via event args object. 
 
 You can get the newly inserted row data on endAdd event through args.data or else from args.rowData. 
 
 Refer to the screenshot:- 
   
 
 
Please get back to us if  you need any further assistance. 
 
Regards, 
Farveen sulthana T 
 


Loader.
Live Chat Icon For mobile
Up arrow icon