I have a editable Kendo grid with two datepicker inside, the kendo grid and it's controller are part an MVC Area. When i want to save a row the error is shown saying that the value introduced is not valid, i want the date format as dd/MM/yyyy. Those date fields have a template like this:
@(Html.Kendo().DatePicker()
.Name("date")
.Culture("es-MX")
.Format("{0:dd/MM/yyyy}")
.ParseFormats(new string[] { "dd/MM/yyyy" })
)
also in the columns definition have format and even a js function to get the value as i want
.Columns(columns =>
{
columns.Bound(p => p.InicioVigencia).Format("{0:dd/MM/yyyy}").ClientTemplate("#=getDate(InicioVigencia)#");
columns.Bound(p => p.FinVigencia).Format("{0:dd/MM/yyyy}").ClientTemplate("#=getDate(FinVigencia)#");
}
function getDate(object) {
if (object == null || object == "null" || object == "NULL" || object == "Null")
return "";
return kendo.toString(object, "dd/MM/yyyy");
}
In the global.asax i set this properties in order to have the date format i want.
CultureInfo threadCultureInfo = (CultureInfo)CultureInfo.CurrentCulture.Clone();
CultureInfo uiCultureInfo = (CultureInfo)CultureInfo.CurrentUICulture.Clone();
threadCultureInfo.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
threadCultureInfo.DateTimeFormat.LongDatePattern = "dd/MM/yyyy hh:mm:ss tt";
uiCultureInfo.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
uiCultureInfo.DateTimeFormat.LongDatePattern = "dd/MM/yyyy hh:mm:ss tt";
Thread.CurrentThread.CurrentCulture = threadCultureInfo;
Thread.CurrentThread.CurrentUICulture = uiCultureInfo;
But the system still showing the error, i have other datepickers defined as js in orther controller just like this
$(function () {
$(".date-picker").kendoDatePicker({
animation: {
close: {
effects: "fadeOut zoom:out",
duration: 300
},
open: {
effects: "fadeIn zoom:in",
duration: 300
}
},
format: "dd/MM/yyyy",
culture: "es-MX"
});
});
And everyting is working fine, so i don't know why it is not working properly. if i change global.asax like this
CultureInfo threadCultureInfo = (CultureInfo)CultureInfo.CurrentCulture.Clone();
CultureInfo uiCultureInfo = (CultureInfo)CultureInfo.CurrentUICulture.Clone();
threadCultureInfo.DateTimeFormat.ShortDatePattern = "MM/dd/yyyy";
threadCultureInfo.DateTimeFormat.LongDatePattern = "MM/dd/yyyy hh:mm:ss tt";
uiCultureInfo.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
uiCultureInfo.DateTimeFormat.LongDatePattern = "dd/MM/yyyy hh:mm:ss tt";
Thread.CurrentThread.CurrentCulture = threadCultureInfo;
Thread.CurrentThread.CurrentUICulture = uiCultureInfo;
the grid that use the templates work properly but the view with the js stop working