Kendo mvc grid InLine Edit Mode DateTimePicker Template gives Error

穿精又带淫゛_ 提交于 2021-02-08 20:37:47

问题


I am using Kendo UI mvc grid for Data listing. I am making InLine Editing in this Grid.I am using EditorTemplate for DateTime field, so that it will give datetimepicker for DateTime field in InLine Edit Mode.When i am going to Click on Update button, it will give me Validation message like this : 'The must be a date'

   columns.Bound(k => k.SevenDaysFrom).Format("{0:dd.MM.yyyy}").EditorTemplateName("DateTime").Width(30);
                            columns.Bound(k => k.SevenDaysTo).Format("{0:dd.MM.yyyy}").EditorTemplateName("DateTime").Width(30);

here DateTime in EditorTemplateName("DateTime") is the Template file i.e DateTime.cshtml And this file will contain the Following code :

@model DateTime?

@(Html.Kendo().DateTimePickerFor(m => m))

Now it will give the validation error message while clicking on Update.The Belowe attach is the Validation error :

enter image description here

So, why this is happening is not known to me? What is the solution for this ? Please Help.


回答1:


Set the kendo culture:

@{
var culture = "en-GB";
}

<script src="@Url.Content("~/Scripts/kendo/cultures/kendo.culture." + @culture + ".min.js")"></script>

<script>  kendo.culture("@culture"); </script>



回答2:


You should mention the data type in View Model

[DataType(DataType.Date)]
public Nullable<DateTime> SevenDaysFrom { get; set; }

and in kendo Grid you can mention like below,

columns.Bound(k => k.SevenDaysFrom).Format("{0:dd.MM.yyyy}")

refer my another answer Display only datepicker in kendo inline editing not datetime picker



来源:https://stackoverflow.com/questions/18786922/kendo-mvc-grid-inline-edit-mode-datetimepicker-template-gives-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!