public flag = false;
// Grid’s actionBegin event handler
actionBegin(e) {
// Initially flag needs to be false in order to enter this condition
if (!this.flag) {
// Edit operation
if (e.requestType == "beginEdit") {
// Current editeds row data
var editedData = e.rowData;
// The default edit operation is cancelled
e.cancel = true;
// Here you can open your custom modal edit popup
this.dialogObj.show();
}
}
}
// Modal popup save button click function
dlgOKButtonClick(args) {
// The edit input elements are retrieved
var editInputs = (this.dialogObj as any).contentEle.querySelectorAll('input');
var newData = [];
// The updated input values are pushed into an array based on their field names(which can be set as the input element name)
editInputs.forEach(ele => { newData[ele.name] = (ele.name === "OrderID") ? parseInt(ele.value) : ele.value });
// Modal popup is hidden
this.dialogObj.hide();
// The global flag is enabled so that the ‘cancel’ action written in the actionBegin event is not executed for this case
this.flag = true;
// Row index to be updated is retrieved using its primary key value
var rowIndex = this.gridObj.getRowIndexByPrimaryKey(newData["OrderID"]);
// New data is updated to the Grid
this.gridObj.updateRow(rowIndex, newData);
}
// Grid’s actionComplete event handler
// Triggers after an action is completed in the Grid
actionComplete(e) {
if (e.requestType === "save") {
// The global flag variable is disabled after operation is successfully performed so that it can enter the condition on next execution
this.flag = false;
}
} |
public flag = false;
// Grid’s actionBegin event handler
actionBegin(e) {
// Initially flag needs to be false in order to enter this condition
if (!this.flag) {
// Delete operation
if (e.requestType == "delete") {
// The default delete operation is cancelled
e.cancel = true;
// Here you can open your custom modal delete popup
this.deleteDialogObj.show();
}
}
}
// Modal popup delete confirmation button click function
deleteDlgOKButtonClick(args) {
// Modal popup is hidden
this.deleteDialogObj.hide();
// The global flag is enabled so that the ‘cancel’ action written in the actionBegin event is not executed for this case
this.flag = true;
// Currently selected record will be deleted from the Grid
this.gridObj.deleteRecord();
}
// Grid’s actionComplete event handler
// Triggers after an action is completed in the Grid
actionComplete(e) {
if (e.requestType === "delete") {
// The global flag variable is disabled after operation is successfully performed so that it can enter the condition on next execution
this.flag = false;
}
} |