Redirect Page on New Appointment

5 posts, 1 answers
  1. Greg
    Greg avatar
    7 posts
    Member since:
    Feb 2012

    Posted 10 May 2012 Link to this post

    I would like to either redirect the page or open a new window on user selection of new appointment by double clicking on the scheduler.  I have been able to do it with editing/viewing an appointment but not for new appointments.  Any solutions for this issue?


    <telerik:RadScheduler ID="rsRooms" runat="server" DataStartField="dtStartDateTime" DataEndField="dtEndDateTime" DataKeyField="intRequestId"
      DataSubjectField="Title" OverflowBehavior="Expand" SelectedView="WeekView" MonthView-VisibleAppointmentsPerDay="6" 
      MultiDayView-UserSelectable="False" TimelineView-UserSelectable="False" Skin="Office2010Blue"
      Width="100%" WeekView-DayStartTime="07:00:00" WeekView-DayEndTime="16:59:59" WorkDayStartTime="07:00:00"
      WorkDayEndTime="16:00:00" DayView-DayEndTime="16:00:00" DayView-DayStartTime="07:00:00" CustomAttributeNames="intRoomScheduledId">
    </telerik:RadScheduler>

    Private Sub loadCal()
        Dim roomId As Integer = Convert.ToInt32(ddlRooms.SelectedValue)
        sql = String.Format("SELECT DISTINCT(r.intRequestId), s.intRoomScheduledId, s.dtMeetingDate dtStartDateTime, CONVERT(VARCHAR(10),s.dtMeetingDate, 120) + ' ' + " _
                            & "SUBSTRING(CONVERT(VARCHAR(23),r.dtEndDateTime,121),11,20) dtEndDateTime, r.strRemarks, ISNULL(p.strPurpose, r.strPurpose) + ': ' + " _
                            & "REPLACE(CONVERT(VARCHAR(5),r.dtStartDateTime,108),':','') + '-' + REPLACE(CONVERT(VARCHAR(5),r.dtEndDateTime,108),':','') Title " _
                            & "FROM tblRequest r JOIN tblRoomScheduled s ON s.intRequestId = r.intRequestId LEFT JOIN tblPurpose p ON r.intPurposeId = p.intPurposeId " _
                            & "WHERE s.intRoomId = {0}", roomId)
        rsRooms.DataSource = getData(sql)
        rsRooms.DataBind()
        For Each apt As Telerik.Web.UI.Appointment In rsRooms.Appointments
            sql = String.Format("SELECT s.intRoomScheduledId FROM tblRoomScheduled s JOIN MnNgPersonnel.dbo.tblMNNatPersonnel p ON s.intPersonnelId = p.intPersonnelId " _
                                & "WHERE s.intRoomScheduledId = {0} AND p.strFTLogon = '{1}'", apt.Attributes("intRoomScheduledId"), myLogon)
            myDataTable = New DataTable
            myDataTable = getData(sql)
            If myDataTable.Rows.Count = 0 Then apt.AllowDelete = False Else apt.AllowDelete = True
        Next
    End Sub
    Protected Sub rsRooms_AppointmentDataBound(sender As Object, e As Telerik.Web.UI.SchedulerEventArgs) Handles rsRooms.AppointmentDataBound
        Dim dt As DataTable
        Dim id As Integer = e.Appointment.Attributes("intRoomScheduledId")
        sql = "SELECT intStatusId FROM tblRoomScheduled WHERE intRoomScheduledId = " & id
        dt = New DataTable
        dt = getData(sql)
        If dt.Rows(0)(0) = "1" Then ' Pending
            e.Appointment.BackColor = Drawing.Color.Khaki
        ElseIf dt.Rows(0)(0) = "2" Then ' Approved
            e.Appointment.BackColor = Drawing.Color.LightGreen
        ElseIf dt.Rows(0)(0) = "3" Then ' Cancelled
            e.Appointment.BackColor = Drawing.Color.DarkSalmon
            e.Appointment.AllowDelete = False
        End If
    End Sub
    Protected Sub rsRooms_AppointmentClick(sender As Object, e As Telerik.Web.UI.SchedulerEventArgs) Handles rsRooms.AppointmentClick
        Dim aptId As Integer = 0
        Dim reqId As Integer = 0
        Dim isVTC As Boolean = False
        mvRequest.ActiveViewIndex = 1
        pnlSelectVTS.Visible = False
        pnlRequest.Visible = False
        aptId = e.Appointment.ID
        hfAptId.Value = aptId
        reqId = e.Appointment.Attributes("intRoomScheduledId")
        sql = "SELECT bitVTC FROM tblRequest WHERE intRequestId = " & aptId
        isVTC = getData(sql).Rows(0)(0)
        If isVTC = True Then
            sql = "SELECT intRoomScheduledId FROM tblRoomScheduled WHERE intRequestId = " & aptId
            myDataTable = New DataTable
            myDataTable = getData(sql)
            If myDataTable.Rows.Count > 1 Then rblVTC.SelectedValue = "1" Else rblVTC.SelectedValue = "0"
        Else
            rblVTC.SelectedValue = "2"
        End If
        Dim strURL As String = String.Format("RequestDetails.aspx?apt={0}&rm={1}&dt={2}", encryptQueryString(reqId), encryptQueryString(ddlRooms.SelectedValue), encryptQueryString(e.Appointment.Start))
        Page.ClientScript.RegisterStartupScript(Me.GetType(), "New Window", "window.open('" + strURL + "','','')", True)
    End Sub
  2. Answer
    Peter
    Admin
    Peter avatar
    6637 posts

    Posted 14 May 2012 Link to this post

    Hi Greg,

    Please, use the approach from the External Edit in RadDock demo. Basically, the idea is to handle FormCreating to take a hold of the Appointment object and then cancel the event and open your own edit/insert form.
    Protected Sub RadScheduler1_FormCreating(ByVal sender As Object, ByVal e As SchedulerFormCreatingEventArgs)
                RadSchedulerRecurrenceEditor1.ResetLayout()
     
                Dim appointmentToEdit = RadScheduler1.PrepareToEdit(e.Appointment, RadScheduler1.EditingRecurringSeries)
     
                If e.Mode = SchedulerFormMode.Insert OrElse e.Mode = SchedulerFormMode.Edit Then
                    EditedAppointment = appointmentToEdit
                    e.Cancel = True
                End If
     
                ScriptManager.RegisterStartupScript(Page, [GetType](), "formScript", "Sys.Application.add_load(openForm);", True)
                PopulateEditForm(appointmentToEdit)
            End Sub

    Attached is also a sample that using RadWindow for external edit/insert of appointments.

    All the best,
    Peter
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Greg
    Greg avatar
    7 posts
    Member since:
    Feb 2012

    Posted 16 May 2012 Link to this post

    Thank you for the help.  That was exactly what I needed.
  5. Shailendra
    Shailendra avatar
    1 posts
    Member since:
    Mar 2013

    Posted 30 Oct 2013 Link to this post

    Thank you,  We are also searching for this functionality.

    I have one question here.  In the above example, how can we pass the parameters to rad window.

    Thanks,
    Venkat.
  6. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 01 Nov 2013 Link to this post

    Hello,

    An easy and convenient way of achieving such functionality would be to use a hidden field on the page where you can store and retrieve values.

    Regards,
    Boyan Dimitrov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017