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

Adding "required" to the model

1 Answer 86 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Pär Sandgren
Top achievements
Rank 1
Pär Sandgren asked on 05 Dec 2013, 09:13 AM
Hi there,

Trying to make use of the wrappers to speed things up, but I cant find a way to add "required" to a field, since the modelbinding doesn't care about the [Required] attribute on the property.
public class TaskItem : ISchedulerEvent
{
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int TaskItemID { get; set; }
    [Required]
    public string Title { get; set; }
    public string Description { get; set; }
    [Required]
    public DateTime Start { get; set; }
    public string StartTimezone { get; set; }
    [Required]
    public DateTime End { get; set; }
    public string EndTimezone { get; set; }
    public string RecurrenceRule { get; set; }
    public int? RecurrenceID { get; set; }
    public string RecurrenceException { get; set; }
    public bool IsAllDay { get; set; }
    public int? OwnerID { get; set; }
}
In javascript this seems easy:
schema: {
    model: {
        id: "taskID",
        fields: {
            taskID: { from: "TaskID", type: "number" },
            title: { from: "Title", validation: { required: true } }
        }
    }
}
Also, I read that servervalidation were supposed to be implemented in q3-release, but I can't get it to work.

Regards,
Pär Sandgren

1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 06 Dec 2013, 02:53 PM
Hi Par,

Please find the answers of your questions below:

1) I cant find a way to add "required" to a field - Basically in order to support MVC validation attributes you should implement custom editor template which to use Html helpers to initialize the editors. Please note that we already provide such example in our CodeLibrary which you can use as a baseline:
2) Also, I read that servervalidation were supposed to be implemented in q3-release, but I can't get it to work. - Could you please clarify where you read this information? Most probably you are referring to that the the DataBinding event can be prevented (available from Q3 release) which allows implementing server validation the same way that it can be implemented in the Grid:

Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Scheduler
Asked by
Pär Sandgren
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or