

|
[actionBegin]
actionBegin(args: any) {
if (args.requestType == 'beginEdit' && this.bulkUpdate) {
let length = this.bulkUpdate.length;
for (let i = 0; i < length; i++) {
if (this.bulkUpdate[i].OrderID == args.rowData.OrderID) {
args.rowData = this.bulkUpdate[i]; //change the args.rowData with our modified data
}
}
}
if (args.requestType == 'save') {
args.cancel = true; //cancel the default edit operation
let length = this.bulkUpdate.length;
let flag = false;
for (let i = 0; i < length; i++) {
if (this.bulkUpdate[i].OrderID == args.data.OrderID) {
flag = true;
}
}
if (!flag) {
this.bulkUpdate.push(args.data);
}
this.grid.editModule.closeEdit(); //cancel the edit
this.grid.setRowData(args.data.OrderID, args.data); // update the edited data in Grid while click on the another cell
}
} |
|
[buttonClick]
myFunc(): any {
let ajax = new Ajax("/Home/BulkSave", "POST", true); // call API
ajax.send(JSON.stringify(this.bulkUpdate)).then(
(data) => {
//do stuff
this.bulkUpdate = []; //here empty the bulk edit array
});
}
[Controller]
public ActionResult BulkSave([FromBody] List<OrdersDetails> value) {
//do stuff
return Json(value);
} |
|
// Grid’s toolbarClick event function
clickHandler: function(args) {
if (args.item.id === 'custom-save' && this.$refs.grid.ej2Instances.editModule.formObj) {
var newVal = [];
// Gets the input elements of the newly added row
var inputElements = this.$refs.grid.ej2Instances.editModule.formObj.inputElements;
// The value of each input element is stored with their field name in ‘newVal’ variable
inputElements.forEach(x => newVal[x.name] = x.value);
console.log("Added data: " + newVal) ;
}
} |