Grid actionBegin:
<script type="text/javascript">
function actionBegin(args) {
if (args.requestType == "save") {
this.query.params = [];
this.query.addParams('EmployeeID', args.data.EmployeeID);
}
}
</script>
Controller:
public IActionResult ChildUpdate([FromBody]CustomCRUDModel<Employees> obj)
{
var queryString = obj.Params.EmployeeID;
switch (obj.Action)
{
case "insert":
emp.Insert(0, obj.Value);
break;
case "update":
var data = emp.Where(or => or.EmployeeID == obj.Value.EmployeeID).FirstOrDefault();
if (data != null)
{
data.EmployeeID = obj.Value.EmployeeID;
data.FirstName = obj.Value.FirstName;
data.LastName = obj.Value.LastName;
data.SerialNo = obj.Value.SerialNo;
}
break;
case "remove":
var Rdata = emp.Where(or => or.EmployeeID== (long)obj.Key).FirstOrDefault();
emp.Remove(Rdata);
break;
}
return Json(obj);
}
public class CustomCRUDModel<T> where T : class
{
public string Action { get; set; }
public string Table { get; set; }
public string KeyColumn { get; set; }
public object Key { get; set; }
public T Value { get; set; }
public List<T> Added { get; set; }
public List<T> Changed { get; set; }
public List<T> Deleted { get; set; }
public customParams Params { get; set; }
}
public class customParams
{
public int EmployeeID { get; set; }
} |
function actionBegin(args) {
if (args.requestType == "save") {
this.query.params = [];
this.query.addParams('EmployeeID', this.parentDetails.parentRowData.EmployeeID); // Parent row data
}
} |