This is a migrated thread and some comments may be shown as answers.

Trouble with date

2 Answers 71 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Shimon
Top achievements
Rank 2
Shimon asked on 27 Mar 2014, 11:10 AM
Hi Telerik Team.

I copy paste the Telerik code of "ScheldulerCustomEditor".

I have the following error : "The field Start must be a date/ The field End must be a date".

I search in the forum but I don't thing it's a trouble of culture.
In FireBug, the right "cultures/kendo.culture.fr-FR.min.js" is loaded.
And
     var culture = Thread.CurrentThread.CurrentUICulture.ToString();
     var cultureServer = Thread.CurrentThread.CurrentCulture.ToString();
give both "fr-FR" as a result.

And i followed the Kendo Globalization tutorial
var culture = System.Globalization.CultureInfo.CurrentCulture.ToString();
<script src="@Url.Content("~/Scripts/kendo/2014.1.321/cultures/kendo.culture." + culture + ".min.js")"></script>

I solved this trouble with Data annotation

[DataType(DataType.Time)]
[UIHint("End")]
[Required(ErrorMessage = "Please select a End time")]
[DateGreaterThan(OtherField = "Start")]
public DateTime End
{
    get
    {
        return end;
    }
    set
    {
        end = value.ToUniversalTime();
    }
}

But i have another error. It's display that "The isAllDay field is required".

2 Answers, 1 is accepted

Sort by
0
Shimon
Top achievements
Rank 2
answered on 27 Mar 2014, 01:52 PM
I set the WebPageRenderingBase.Culture to the right culture.
So for the DateTimePickerFor
In the "en-US" culture i have time format like this : 3/27/2014 6:00 AM
In the "fr-FR" culture i have time format like that :   27/03/2014 06:00

In the editorTemplate, when i click on save nothing happend. I must click on IsAllDay checkBox to reach the controller.
And when i click on IsAllDay the time format change : for instance in fr-FR : "27/03/2014"

0
Accepted
Alexander Popov
Telerik team
answered on 31 Mar 2014, 11:42 AM
Hello Shimon,

This happens because ASP.NET MVC renders all checkboxes with a required attribute, unless DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes is set to false in the Global.asax file. Another approach would be to replace the HTML helper with a simple input element: 
<div data-container-for="isAllDay" class="k-edit-field">
    <input data-bind="checked: isAllDay" data-val="true" id="IsAllDay" name="IsAllDay" type="checkbox" />
</div>

Regards,
Alexander Popov
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
Tags
Scheduler
Asked by
Shimon
Top achievements
Rank 2
Answers by
Shimon
Top achievements
Rank 2
Alexander Popov
Telerik team
Share this question
or