We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Error when saving datetime from Custom Dialog Form

I have the following grid:

                            @(Html.EJ().Grid<SlimHub.Models.WorkActivity>("ActivitiesGrid")
                          .Datasource(ds => ds.Json((IEnumerable<WorkActivity>)Model.WorkActivities.ToList()).UpdateURL("../NormalActivityUpdate").InsertURL("../NormalActivityInsert").RemoveURL("../NormalActivityDelete").Adaptor(AdaptorType.RemoteSaveAdaptor))
                          .EditSettings(edit =>
                          {
                              edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.DialogTemplate).DialogEditorTemplateID("#ActivityTemplate");
                          })
                          .Locale("it-IT")
                          .ToolbarSettings(toolbar =>
                          {
                              toolbar.ShowToolbar().ToolbarItems(items =>
                              {
                                  items.AddTool(ToolBarItems.Add);
                                  items.AddTool(ToolBarItems.Edit);
                                  items.AddTool(ToolBarItems.Delete);
                                  items.AddTool(ToolBarItems.Update);
                                  items.AddTool(ToolBarItems.Cancel);
                              });
                          })
                          .AllowResizing()
                          .AllowTextWrap(true)
                          .Columns(col =>
                          {
                              col.Field("Id").HeaderText("ID Attività").HeaderTextAlign(TextAlign.Center).IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(5).Visible(false).Add();
                              col.Field("WorkId").DefaultValue(@Model.WorkId).HeaderText("ID Lavoro").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Width(5).Visible(false).Add();
                              col.Field("OperatorId").HeaderText("Operatore").ForeignKeyField("OperatorId").ForeignKeyValue("OperatorDesc").DataSource((IEnumerable<object>)ViewBag.Operators).HeaderTextAlign(TextAlign.Center).Width(10).Add();
                              col.Field("Subject").HeaderText("Attività").HeaderTextAlign(TextAlign.Center).Width(30).Add();
                              col.Field("Description").HeaderText("Attività").HeaderTextAlign(TextAlign.Center).Width(30).Add();
                              col.Field("AllDay").DefaultValue(0).HeaderText("Attività").HeaderTextAlign(TextAlign.Center).Visible(false).Add();
                              col.Field("Recurrence").DefaultValue(0).HeaderText("Attività").HeaderTextAlign(TextAlign.Center).Visible(false).Add();
                          })
                          .ClientSideEvents(eve =>
                          {
                              eve.ActionComplete("ActivitiesGridActionComplete");
                              eve.ActionBegin("ActivitiesGridActionBegin");
                              eve.EndEdit("endEdit");
                              eve.EndAdd("endAdd");
                              eve.BeginEdit("ActivitiesGridBeginEdit");
                          })
                            )

The custom dialog form is this:

<script id="ActivityTemplate" type="text/template">
    <div>
        <b>Dettagli Attività</b>
        <table cellspacing="10">
            <tr>
                <td style="text-align: right;">
                    ID Attività
                </td>
                <td style="text-align: left">
                    <input id="Id" name="Id" value="{{: Id}}" disabled="disabled" class="e-field e-ejinputtext valid e-disable"
                           style="text-align: right; width: 300px; height: 28px" />
                </td>
                <td style="text-align: right;">
                    ID Lavoro
                </td>
                <td style="text-align: left">
                    <input id="WorkId" name="WorkId" value="{{: WorkId}}" disabled="disabled" class="e-field e-ejinputtext valid e-disable"
                           style="width: 300px; height: 28px" />
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    Oggetto
                </td>
                <td style="text-align: left">
                    <input id="Subject" name="Subject" value="{{: Subject}}" class="e-field e-ejinputtext valid"
                           style="text-align: right; width: 300px; height: 28px" />
                </td>
                <td style="text-align: right;">
                    Descrizione
                </td>
                <td style="text-align: left">
                    <textarea id="Description" name="Description" class="e-field e-ejinputtext valid"
                              style="width: 300px; height: 28px" >{{: Description}}</textarea>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    Ora Inizio
                </td>
                <td style="text-align: left; width: 300px;">
                    <input id="StartTime" name="StartTime" value="{{: StartTime}}" style="width: 300px; height: 28px" />
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    TimeZone Ora Inizio
                </td>
                <td style="text-align: left; width: 300px;">
                    <input id="StartTimeZone" name="StartTimeZone" value="{{: StartTimeZone}}" style="width: 300px; height: 28px" />
                </td>
                <td style="text-align: right;">
                    TimeZone Ora Fine
                </td>
                <td style="text-align: left; width: 300px;">
                    <input id="EndTimeZone" name="EndTimeZone" value="{{: EndTimeZone}}" style="width: 300px; height: 28px" />
                </td>
            </tr>
        </table>
    </div>

<script type="text/javascript">

    function ActivitiesGridActionBegin(args) {
        if (args.requestType == "save")
            this._isEditChangesApplied = true;
    }

    function ActivitiesGridActionComplete(args) {
        if (args.requestType == "beginedit" || args.requestType == "add") {
            $("#StartTime").ejDateTimePicker({ locale: "it-IT", width: "300", dateTimeFormat: "dd/MM/yyyy HH:mm:ss" });
            $("#StartTimeZone").val('@(SlimHub.Properties.Settings.Default.TimeZone)');
            $("#EndTimeZone").val('@(SlimHub.Properties.Settings.Default.TimeZone)');
        }
    }
</script>

I have included culture specific js file:

<script src="/Scripts/ej/ej.culture.it-IT.min.js"></script>

When I select the date from DateTime Picker and try to Save, I got the following error:

ej.web.all.min.js:10 Uncaught TypeError: Cannot read property 'format' of null

Can you help me?

Thanks.

Claudio

1 Reply

MS Mani Sankar Durai Syncfusion Team June 12, 2017 08:46 AM UTC

Hi CLAUDIO, 

Thanks for contacting Syncfusion support. 

We have analyzed your query and we are not able to reproduce the reported issue. We have checked based on your code example provided and shown the dateTimepicker in the custom template dialog and when saving it saves the data properly while using remoteSaveAdaptor in grid 
We have also prepared a sample that can be downloaded from the below link. 
Note: we have also checked by applying locale for the Date column. 
If you still face the issue please get back to us with the following details. 
1.       Share the screenshot/ video of the issue that you have faced. 
2.       Share the stack trace of the issue that you have faced. 
3.       Share the Syncfusion Essential studio version that you have used. 
4.       If possible please reproduce the issue in the above attached sample. 
The provided information will help us to analyze the issue and provide you the response as early as possible. 

Please let us know if you need further assistance. 

Regards, 
Manisankar Durai. 
 


Loader.
Live Chat Icon For mobile
Up arrow icon