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

How to open scheduler editor window on timerange selection?

2 Answers 94 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Oliver
Top achievements
Rank 1
Oliver asked on 17 Jan 2014, 11:23 AM
Hi!

I'd like to open the event-editor popup automatically when a timerange has been selected (without pressing ENTER). How do I trigger opening the window? 

Here is the change listener I've implemented so far:


var changeTimer;
    var changeInterval = 1000;
    var selectedStart;
    var selectedEnd;
    function scheduler_change(e) {
        if (e.events.length == 0 && e.start < e.end) {
            selectedStart = e.start;
            selectedEnd = e.end;
            if (changeTimer) {
                clearTimeout(changeTimer);
            }
            changeTimer = setTimeout(openWindow, changeInterval);
        }
   }

 function openWindow() {
        if (selectedStart && selectedEnd) {
            var scheduler = $("#scheduler").data("kendoScheduler");
            //open editor here
        }
    }

My Scheduler:

@(Html.Kendo().Scheduler<SchedulerEvent>()
          .Name("scheduler")
          .Date(DateTime.Today)
          .Editable(edit => edit.TemplateName("SchedulerEventEditor"))
          .EventTemplateId("template")
          .DateHeaderTemplate(string.Format("<strong>#=kendo.toString(date, '{0}')#</strong>", GlobalResources.SchedulerHeaderDateFormat))
          .Resources(resource => resource.Add(m => m.CalendarId)
                                         .Title(GlobalResources.CalendarOwner)
                                         .DataTextField("OwnerName")
                                         .DataValueField("CalendarId")
                                         .DataColorField("Color")
                                         .BindTo(Model.Calendars.Where(x => !x.IsReadOnly))
          )

          .Views(views =>
              {
                  views.DayView();
                  views.WeekView();
                  views.MonthView();
                  views.AgendaView();
              })
          .Selectable(true)
          .Events(evts =>
              {
                  evts.Change("scheduler_change");
                  evts.Edit("scheduler_edit");
                  evts.DataBound("scheduler_dataBound");
                  evts.ResizeEnd("scheduler_resize");
                  evts.MoveEnd("scheduler_move");
                  evts.Remove("scheduler_remove");
                  evts.Add("scheduler_add");
              })
          .DataSource(dataSource => dataSource
              .ServerOperation(true)
                                        .Model(
                                            m =>
                                            {
                                                m.Id(f => f.ID);
                                                //m.RecurrenceId(f => f.RecurrenceID.Value);
                                                m.Field(f => f.ConfirmationRequired).DefaultValue(true);
                                                m.Field(f => f.PointOfInterest).DefaultValue(new PointOfInterest());
                                                m.Field(f => f.Attendees).DefaultValue(new List<Guid>());
                                                m.Field(f => f.CalendarId).DefaultValue(Model.Calendars.Where(x=>x.IsOwner).Select(x => x.CalendarId).FirstOrDefault());
                                            }
                                        )
                                        
                                        .Events(e => e.Sync("function() {this.read();}"))
                                        .Read( read=>read.Action("ReadEvents", "Scheduler").Data("readData"))
                                        .Create("CreateEvent", "Scheduler")
                                        .Destroy("DeleteEvent", "Scheduler")
                                        .Update("UpdateEvent", "Scheduler")            
          )
          )

Best regards

2 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 17 Jan 2014, 12:03 PM
Hi Oliver,

From the provided information it seems that you need assistance with the opening of the popUp editor with the currently selected "start" and "end" dates - if this is the case you can achieve the desired behavior by extending the "openWindow" function as follows:

function openWindow() {
       if (selectedStart && selectedEnd) {
           var scheduler = $("#scheduler").data("kendoScheduler");
           scheduler.addEvent({start: selectedStart, end: selectedEnd});
       }
   }

Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Oliver
Top achievements
Rank 1
answered on 19 Jan 2014, 11:32 AM
Works fine! Thanks.
Tags
Scheduler
Asked by
Oliver
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Oliver
Top achievements
Rank 1
Share this question
or