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

How to create custom model for scheduler tasks

1 Answer 575 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
EPCON CCS
Top achievements
Rank 2
EPCON CCS asked on 07 Jul 2014, 04:04 PM
Hi, I'm trying to create my own task model for the mvc kendo scheduler , I've already implemented the ISchedulerEvent on my model to make the scheduler work but i don't want their properties (end,start,title.description,timezone, etc...), I only want the properties I've created, also I've already created my custom task creation popup with my own properties but when I click the save button i canĀ“t advance to the controller method because the ISchedulerEvent properties are required, here is my sheduler code and my model.

Index

@(Html.Kendo().Scheduler<NUGUlib.Models.task>()
        .Name("scheduler")
        .Date(new DateTime(2013, 6, 13))
        .StartTime(new DateTime(2013, 6, 13, 10, 00, 00))
        .EndTime(new DateTime(2013, 6, 13, 23, 00, 00))
        .Editable(true)
        .Height(600)
        .Editable(e => e.TemplateName("PopUp"))
        .Views(views =>
        {
            views.DayView();
            views.WeekView(semana => semana.Selected(true));
            views.MonthView();
            views.WorkWeekView(view => view.WorkDayCommand(false));
            views.AgendaView();
        })
        .DataSource(d => d.Model(m =>
            {
                m.Id(f => f.id);
            })
               .Read(r => r.Action("Scheduler_Read", "Scheduler"))
               .Create(c => c.Action("Scheduler_Create", "Scheduler"))
               .Destroy("Scheduler_Destroy", "Scheduler")
               .Update("Scheduler_Update", "Scheduler")
        )
        .ShowWorkHours(false)
        .BindTo(Model)
)

Model

 public partial class cita : ISchedulerEvent
    {
        public int id { get; set; }
        public int UserID { get; set; }
        public System.DateTime firstDate { get; set; }
        public System.DateTime secondDate { get; set; }
        public string description { get; set; }
        public int times { get; set; }

        public string Description
        {
            get;
            set;
        }

        public DateTime End
        {
            get;
            set;
        }

        public string EndTimezone
        {
            get;
            set;
        }

        public bool IsAllDay
        {
            get; 
            set;
                

        }

        public string RecurrenceException
        {
            get;
            set;

        }

        public string RecurrenceRule
        {
            get;

            set;

        }

        public DateTime Start
        {
            get;
            set;

        }

        public string StartTimezone
        {
            get;
            set;
        }

        public string Title
        {
            get;
                

            set;

        }
    }
}




1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 09 Jul 2014, 08:50 AM
Hi,

Basically the Scheduler internally works only with "SchedulerEvent" data items - that why on the client side the custom properties that you have should be translated to the properties of the "SchedulerEvent". This can be achieved using the "Custom" DataSource builder of the Scheduler:

.DataSource(d => d
    .Custom()
    .Type("aspnetmvc-ajax")
    .Schema(schema => schema
        .Model(m => {
            m.Id(f => f.id);  
            //title field is mendatory
            m.Field("title", typeof(string)).DefaultValue("No title").From("Title");
            m.Field("start", typeof(DateTime)).From("firstDate");
            m.Field("end", typeof(DateTime)).From("secondDate");
            m.Field("description", typeof(string));

In the custom editor template you should bind the editors to the propertied from the "SchedulerEvent" as the source properties like "firstDate" will not be available.

Also another option that I would recommend is to create "CitaViewModel" which to contain only the properties from the "ISchedulerEvent" and use it to receive and send the data to the client side. For more information about ViewModels you can check the following post in StackOverflow:

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
EPCON CCS
Top achievements
Rank 2
Answers by
Vladimir Iliev
Telerik team
Share this question
or