Hi, From last 2 days I am trying to solve this issue. I can't do this. Please anyone help me. I am working on essential JS 2 of asp.net MVC5 framework.
I just show the grid in the view page where some of columns are datetime . Now I want to update that grid information with datetime and other columns also.
I can do pass other columns value but the datetime columns value are null. I can't pass this. Please help me. Here some of my code I share.
This is the grid:
<div class="control-section">
@Html.AntiForgeryToken()
@Html.EJS().Grid("Grid").DataSource(dm => dm.Url("/TimeClockUpdate/DataSourceForPunch")
.InsertUrl("/TimeClockUpdate/UpdatePunchInfo")
.UpdateUrl("/TimeClockUpdate/UpdatePunchInfo")
.RemoveUrl("/TimeClockUpdate/UpdatePunchInfo")
.Adaptor("UrlAdaptor")).Load("load").ActionComplete("actioncomplete").AllowGrouping().AllowPdfExport().AllowExcelExport().ToolbarClick("toolbarClick").AllowSorting().AllowResizing(true).ShowColumnChooser(true).Columns(col =>
{
col.Field("PunchDetailId").IsPrimaryKey(true).Visible(false).HeaderText("PunchDetailId").Width("150").Add();
col.Field("PunchDate").HeaderText("Punch Date").Width("140").EditType("datepickeredit").AllowEditing(true).Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("PayPeriod").HeaderText("Pay Period").Width("140").EditType("datepickeredit").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("EmpNum").HeaderText("Emp Num").Width("150").Add();
col.Field("FirstName").HeaderText("First Name").Width("150").Add();
col.Field("Location").HeaderText("Location").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("PunchIn").HeaderText("Punch In").Width("140").EditType("datepickeredit").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("PunchOut").HeaderText("Punch Out").Width("140").EditType("datepickeredit").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("Memo").HeaderText("Memo").Width("150").Add();
}).AllowPaging().PageSettings(p => p.PageCount(3)).EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Normal); }).Toolbar(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" ,"Search", "ColumnChooser", "ExcelExport", "PdfExport", "CsvExport" }).Render()
</div>
This is the controller code:
[HttpPost]
public ActionResult UpdatePunchInfo(PunchDetail value)
{
PunchDetail punch = db.PunchDetails.Find(value.PunchDetailId);
punch.Memo = value.Memo;
punch.PunchIn = value.PunchIn; // here I need the datetime data from grid
punch.PunchOut = value.PunchOut; // here I need the datetime data from grid
punch.PunchDate = punch.PunchDate; // here I need the datetime data from grid
punch.EmpNum = punch.EmpNum;
punch.Location = punch.Location;
punch.PunchInSrc = punch.PunchInSrc;
punch.PunchOutSrc = punch.PunchOutSrc;
punch.PayPeriod = punch.PayPeriod; // here I need the datetime data from grid
punch.CreatedBy = punch.CreatedBy;
punch.CreatedDate = punch.CreatedDate;
punch.UpdatedBy = punch.UpdatedBy;
punch.UpdatedDate = DateTime.Now;
punch.DeletedStatus = punch.DeletedStatus;
punch.DeletedBy = punch.DeletedBy;
punch.DeletedDate = punch.DeletedDate;
db.Entry(punch).State = System.Data.Entity.EntityState.Modified;
db.SaveChanges();
return Json(punch);
}