Adding "required" to the model

2 posts, 0 answers
  1. Pär Sandgren
    Pär Sandgren avatar
    7 posts
    Member since:
    Dec 2013

    Posted 05 Dec 2013 Link to this post

    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
  2. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 06 Dec 2013 Link to this post

    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!
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top