<script type="text/javascript">
var flag = true;
$(function () {
$("# ControlRegion ").ejGrid({
// the datasource "window.gridData" is referred from jsondata.min.js
dataSource: window.gridData,
allowPaging: true,
----------
columns: [
----------------
],
actionBegin: "begin"
});
});
function begin(args) {
if (args.requestType == "beginedit") {
flag = true;
}
if (args.requestType == "save" && flag == true) {
args.cancel = true; //prevent save action
flag = false;
var gridObj = $("# ControlRegion ").data("ejGrid");
gridObj.cancelEdit();// cancel editing
args.data = customValidation(args.data); //call for the custom validation data to change the data
$.ajax({
url: "/Grid/ApplyPaymentToDeposit",
type: "POST",
data: args.data,
success: function (data) {
$("#ControlRegion").ejGrid("updateRecord", "OrderID", { OrderID: args.data['OrderID'], CustomerID: args.data['CustomerID'], EmployeeID: args.data['EmployeeID'], });
//call for the updateRecord method in ajax success
},
error: function (e) {
args.cancel = true;
}
});
}
}
function customValidation(data) {
data["EmployeeID"] = 3;
return data; //return the employeeID modified data
}
</script>
|