Pass date time value/data from grid to controller

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);
        }


1 Reply

VA Venkatesh Ayothi Raman Syncfusion Team August 6, 2018 06:39 AM UTC

Hi Saddam, 
 
Thanks for using Syncfusion products. 
 
We went through your code example that you have shared with us and we have tried to reproduce the reported issue at our end but it’s unsuccessful. We have also prepared a sample for your convenience which can be download from following link, 
 
 
 
Code example: 
@Html.EJS().Grid("DefaultPaging").DataSource(dm => dm.Url("/Home/UrlDatasource") 
                                .InsertUrl("/Home/Insert") 
                                .UpdateUrl("/Home/Update") 
                                .RemoveUrl("/Home/Delete") 
                                .Adaptor("UrlAdaptor")).Columns(col => 
                                { 
 
                                    col.Field("OrderID").HeaderText("Order ID").Width("120").IsPrimaryKey(true).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); 
                                    . .  . 
                                }).AllowPaging().EditSettings(edit=>edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true)).Toolbar( new string[] { "Add", "Edit","Delete","Update", "Cancel"}).PageSettings(page => page.PageCount(4)).Render() 
 
 
 
Screenshot of the update action: 
 
 
Screenshot of Network window: 
 
 
If you still face the same issue, then could you please provide following details? 
1)      Share the issue screenshot. 
2)      Share Network tab screenshot while update POST request will sends to server side. 
3)      Issue reproducing scenario. 
 
It would be helpful for us to find the problem and provide the better solution as earliest. 
 
 
Regards, 
Venkatesh Ayothiraman. 


Loader.
Up arrow icon