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

Close Appoinment popup

1 Answer 42 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
ankita
Top achievements
Rank 1
ankita asked on 11 Jun 2015, 10:32 AM

Hi,

Appointment popup is not close after click on save/close button.

Here is my clode.

aspx page:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="vendorzone.aspx.cs" Inherits="MwsMainGui.vendorzone" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Scheduler demo</title>
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadScheduler1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadScheduler1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
        </telerik:RadAjaxLoadingPanel>
        <div class="demo-container no-bg">
            <telerik:RadScheduler runat="server" ID="RadScheduler1" DayStartTime="08:00:00" DayEndTime="18:00:00" OnAppointmentInsert="RadScheduler1_AppointmentInsert"
                OnAppointmentUpdate="RadScheduler1_AppointmentUpdate" DisplayDeleteConfirmation="true" OnAppointmentDelete="RadScheduler1_AppointmentDelete"
                DataKeyField="ID" DataSubjectField="Subject" DataStartField="Start" DataEndField="End"
                DataRecurrenceField="RecurrenceRule" DataRecurrenceParentKeyField="RecurrenceParentId"
                DataReminderField="Reminder" AppointmentStyleMode="Simple" FirstDayOfWeek="Monday">
                <AdvancedForm Modal="true"></AdvancedForm>
                <TimelineView UserSelectable="false"></TimelineView>
                <TimeSlotContextMenuSettings EnableDefault="true">
                </TimeSlotContextMenuSettings>
                <AppointmentContextMenuSettings EnableDefault="true"></AppointmentContextMenuSettings>
                <Reminders Enabled="false"></Reminders>
            </telerik:RadScheduler>
        </div>
    </form>
</body>
</html>

 

aspx.cs page :

 

 public partial class vendorzone : System.Web.UI.Page
    {
        private const string AppointmentsKey = "Scheduler";

        private List<AppointmentInfo> Appointments
        {
            get
            {
                List<AppointmentInfo> sessApts = Session[AppointmentsKey] as List<AppointmentInfo>;
                if (sessApts == null)
                {
                    sessApts = new List<AppointmentInfo>();
                    Session[AppointmentsKey] = sessApts;
                }

                return sessApts;
            }
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (!IsPostBack)
            {
                Session.Remove(AppointmentsKey);
                InitializeResources();
                InitializeAppointments();
            }

            RadScheduler1.DataSource = Appointments;
        }

        protected void RadScheduler1_AppointmentInsert(object sender, SchedulerCancelEventArgs e)
        {
            Appointments.Add(new AppointmentInfo(e.Appointment));
        }

        protected void RadScheduler1_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e)
        {
            AppointmentInfo appointmentInfo = FindById(e.ModifiedAppointment.ID);
            RecurrenceRule rrule;

            if (RecurrenceRule.TryParse(e.ModifiedAppointment.RecurrenceRule, out rrule))
            {
                rrule.Range.Start = e.ModifiedAppointment.Start;
                rrule.Range.EventDuration = e.ModifiedAppointment.End - e.ModifiedAppointment.Start;
                TimeSpan startTimeChange = e.ModifiedAppointment.Start - e.Appointment.Start;
                for (int i = 0; i < rrule.Exceptions.Count; i++)
                {
                    rrule.Exceptions[i] = rrule.Exceptions[i].Add(startTimeChange);
                }
                e.ModifiedAppointment.RecurrenceRule = rrule.ToString();
            }

            appointmentInfo.CopyInfo(e.ModifiedAppointment);
            RadScheduler1.DataSource = Appointments;
        }

        protected void RadScheduler1_AppointmentDelete(object sender, SchedulerCancelEventArgs e)
        {
            Appointments.Remove(FindById(e.Appointment.ID));
        }

        private void InitializeResources()
        {
            ResourceType resType = new ResourceType("User");
            resType.ForeignKeyField = "UserID";

            RadScheduler1.ResourceTypes.Add(resType);
            RadScheduler1.Resources.Add(new Resource("User", 1, "Alex"));
            RadScheduler1.Resources.Add(new Resource("User", 2, "Bob"));
            RadScheduler1.Resources.Add(new Resource("User", 3, "Charlie"));
        }

        private void InitializeAppointments()
        {
            DateTime start = DateTime.UtcNow.Date;
            start = start.AddHours(6);
            Appointments.Add(new AppointmentInfo("Take the car to the service", start, start.AddHours(1), string.Empty, null, new Reminder(30).ToString(), 1));
            Appointments.Add(new AppointmentInfo("Meeting with Alex", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));

            start = start.AddDays(-1);
            DateTime dayStart = RadScheduler1.UtcDayStart(start);
            Appointments.Add(new AppointmentInfo("Bob's Birthday", dayStart, dayStart.AddDays(1), string.Empty, null, string.Empty, 1));
            Appointments.Add(new AppointmentInfo("Call Charlie about the Project", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));

            start = start.AddDays(2);
            Appointments.Add(new AppointmentInfo("Get the car from the service", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 1));
        }

        private AppointmentInfo FindById(object ID)
        {
            foreach (AppointmentInfo ai in Appointments)
            {
                if (ai.ID.Equals(ID))
                    return ai;
            }
            return null;
        }

        class AppointmentInfo
        {
            private readonly string _id;
            private string _subject;
            private DateTime _start;
            private DateTime _end;
            private string _recurrenceRule;
            private string _recurrenceParentId;
            private string _reminder;
            private int? _userID;

            public string ID
            {
                get
                {
                    return _id;
                }
            }

            public string Subject
            {
                get
                {
                    return _subject;
                }
                set
                {
                    _subject = value;
                }
            }

            public DateTime Start
            {
                get
                {
                    return _start;
                }
                set
                {
                    _start = value;
                }
            }

            public DateTime End
            {
                get
                {
                    return _end;
                }
                set
                {
                    _end = value;
                }
            }

            public string RecurrenceRule
            {
                get
                {
                    return _recurrenceRule;
                }
                set
                {
                    _recurrenceRule = value;
                }
            }

            public string RecurrenceParentID
            {
                get
                {
                    return _recurrenceParentId;
                }
                set
                {
                    _recurrenceParentId = value;
                }
            }

            public int? UserID
            {
                get
                {
                    return _userID;
                }
                set
                {
                    _userID = value;
                }
            }

            public string Reminder
            {
                get
                {
                    return _reminder;
                }
                set
                {
                    _reminder = value;
                }
            }

            private AppointmentInfo()
            {
                _id = Guid.NewGuid().ToString();
            }

            public AppointmentInfo(string subject, DateTime start, DateTime end,
                string recurrenceRule, string recurrenceParentID, string reminder, int? userID)
                : this()
            {
                _subject = subject;
                _start = start;
                _end = end;
                _recurrenceRule = recurrenceRule;
                _recurrenceParentId = recurrenceParentID;
                _reminder = reminder;
                _userID = userID;
            }

            public AppointmentInfo(Appointment source)
                : this()
            {
                CopyInfo(source);
            }

            public void CopyInfo(Appointment source)
            {
                Subject = source.Subject;
                Start = source.Start;
                End = source.End;
                RecurrenceRule = source.RecurrenceRule;
                if (source.RecurrenceParentID != null)
                {
                    RecurrenceParentID = source.RecurrenceParentID.ToString();
                }

                if (!String.IsNullOrEmpty(Reminder))
                {
                    Reminder = source.Reminders[0].ToString();
                }

                Resource user = source.Resources.GetResourceByType("User");
                if (user != null)
                {
                    UserID = (int?)user.Key;
                }
                else
                {
                    UserID = null;
                }
            }
        }

}

 

Help me.

 

Thanks,

Ankita​

1 Answer, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 16 Jun 2015, 08:30 AM
Hello Ankita,

Can you please remove the RadAjax settings and see if this makes any difference? Also after removing the Ajax, inspect the browser's console and see if any errors appear when trying to close the popup.

Regards,
Maria Ilieva
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Ajax
Asked by
ankita
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or